Page 1 of 1

Problem with centerMouse()

Posted: Tue Oct 02, 2012 11:56 pm
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.

Posted: Sat Oct 06, 2012 9:45 am
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.

Posted: Sun Oct 07, 2012 9:58 am
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.

Posted: Sun Oct 07, 2012 3:18 pm
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?

Posted: Fri Nov 02, 2012 6:36 pm
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.

Posted: Sat Nov 03, 2012 10:03 am
by VilleK
Hi, please download the beta again and see if I've fixed the problem now. Only ZGameEditor.exe have changed.

Posted: Sat Nov 03, 2012 10:57 am
by Rado1
Unfortunately, the problem still remains.

Posted: Sat Nov 03, 2012 12:05 pm
by VilleK
Sorry, it looked like it worked here at first. Try again now.

Posted: Sat Nov 03, 2012 1:52 pm
by Rado1
This version is working perfectly! Thank you Ville :D