2012 September 8 - 05:11 Why Stage.mouseLock (in it’s current state) is not great for games.
[Edited this post some, large part of my issues was due to mouse acceleration, the rounding was only part of the problem.
This post is a complete mess but I wrote it at 5am…]
With Flash 11.2 Adobe finally introduced mouse-lock, finally we can make FPS or third person games with mouse controlled camera.
I haven’t gotten around to try it out until now, and I noticed that even-though MouseEvent.movementX/Y are typed as Number they are always floored to ints. D:
Combine this with that you have no absolute mouse position when using mouse-lock (you only got the delta change) you have a huge problem.
For each mouse update you may lose up to 1 pixel of movement. I’m not entirely sure how often MOUSE_MOVE fires but lets say once per frame, at 60 fps you may lose up to 60 pixels worth of mouse movement per second. That’s terrible.
It also seems that the MOUSE_MOVE event fires very unevenly, often being around 100ms between events, making the movement very uneven. It needs to fire at around 60hz for an first person shooter.
I’ve tried this on Flash Player 11.3.300.257 and 11.4.402.265 on osX Lion. Really hoping there is something wrong with my computer.
[Edit: Tried it on my windows7 machine, same result in both IE and Firefox.]
[Edit2: Its possible that the problem is incresed by mouse acceleration, if the OS settings for mouse acceleration affects the movement values. Later: Yes they are.]
Btw, a bug, MouseEvent.clone() does not clone the movements values. So you need to set those yourself.
To sum things up, what’s missing in Flash (currently 11.4) for games. Without these it’s not possible to make a decent FPS like game.
1. Raw mouse input without mouse acceleration.
2. Mouse input at 60hz
3. Sub-pixel precision on mouse movement.