Problem with centerMouse()

Found a bug? Post information about it here so we can fix it!

Moderator: Moderators

Post Reply
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Problem with centerMouse()

Post by Rado1 »

When used centerMouse() in OnUpdate to reset mouse position, App.MousePosition.X and App.MousePosition.Y are not 0. For instance:

Code: Select all

centerMouse();
trace(intToStr(App.MousePosition.X * 10000) + "," + intToStr(App.MousePosition.Y * 10000));
or

Code: Select all

trace(intToStr(App.MousePosition.X * 10000) + "," + intToStr(App.MousePosition.Y * 10000));
centerMouse();
both give numbers such as -20,16 or -17,10 or similar.

This happens only when application is running in the ZGE's application preview window and values vary depending on size or aspect ration of the viewport. When running from .exe, centerMouse() works correctly.

I observed it on Toyland Shooter project which is quite complex, but unfortunately, I was not able to reproduce it on a simple project to show you this strange behavior.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

I found also other projects from this forum which use centerMouse() and are not running correctly in ZGE. For instance basic_FP_engine_001.zgeproj from this thread or Approach2.zgeproj from this thread. It is really impossible to debug applications.

BTW the same problem I have also with stable release of ZGE v2.0.1. Ville could you please have a look at this strange behavior? Thanks.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Rado1, please try this update:

http://www.zgameeditor.org/files/ZGameEditor_beta.zip

It seems more stable now when I try it, hope it works for you too.

The update also fixes a couple of problems with PlaySound.ByReference that Kjell reported.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Thank you Ville, it's working fine now. BTW when the centerMouse() takes really effect and resets App.MousePosition, on next OnUpdate cycle? I have a small problem when tried centerMouse() in Model.OnSpawn and checked App.MousePosition in Model.OnUpdate. Of course this returned incorrect values. This was partially solved by clamp() applied for mouse position, but this is not a good solution. Cannot centerMouse() reset App.MousePosition immediately?
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Hi Ville,

unfortunately, the problem with centerMouse() in ZGE still exists, even if it is not so usual as before. If ZApplication.ViewportRatio is fixed (to 4:3 or 16:9) and centerMouse() is called, resizing the application view in ZGE can cause that on next rendering cycle the MousePosition.X or .Y is not 0, even if immediately after centerMouse() call it is 0. Some sizes of the preview return 0, but some sizes return other values.

This is an example of log from the attached example (mouse did not move):

Gamepads detected: 0
before -10000,-10000
after 0,0
before 16,16
after 0,0
before 16,16
after 0,0
before 16,16
after 0,0
before 16,16
after 0,0
...

I would really appreciate fixing of this bug, because it makes application debugging in ZGE difficult.

Rado1.
Attachments
test.zgeproj
testing project
(495 Bytes) Downloaded 449 times
Last edited by Rado1 on Sat Nov 03, 2012 11:01 am, edited 1 time in total.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Hi, please download the beta again and see if I've fixed the problem now. Only ZGameEditor.exe have changed.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Unfortunately, the problem still remains.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Sorry, it looked like it worked here at first. Try again now.
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

This version is working perfectly! Thank you Ville :D
Post Reply