Hi Stefano,
One of my nodegames sports an avatar that always starts in the center of the screen and is controlled by the mouse cursor. The avatar moves whenever a mousemove event is triggered, which will cause the avatar to 'jump' to the current cursor position when the latter is not at the center, which it often is not depending on behavior in a previous round. This jumping behavior would not exist if the cursor could be forcibly moved to the center of the screen prior to the avatar's appearance in that location. But javascript apparently does not allow this level of control of the cursor (problem #1).
For a solution, I'm subtracting the offset of the cursor's last position from the center prior to the avatar's appearance. That way the avatar moves smoothly from the center out, as desired. The resulting issue, however, is that this offset can accumulate over rounds, to the point that the user might need to move the cursor outside the document entirely in order to make the avatar reach an intended location. However, problem #2 is that my current implementation of mousemove* no longer triggers events outside the document/element, such that avatar cannot move beyond a given point and thus not reach the intended location.
Any suggestions on how to bypass either problem #1 (forcibly moving cursor position to the center) or problem #2 (allow mousemove events outside the frame)?
All the best,
Arjen
*
W.getFrameDocument().body.addEventListener('mousemove', function (event) {
...
});