Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by erfuller

So I have some code for moving something around with the mouse, which is using ig.input.state() to determine if the mouse button is currently down, and that part is working great.

However, if you drag your finger off the canvas on mobile, or click and drag off the canvas, the state remains down, and the mouse x,y returned doesn't change from the last good position in the canvas, so my game thinks their finger/mouse is being held down on the edge of the screen.

How do I tell when the mouse has left the canvas?

Thanks,

1 decade ago by paulh

not a coder or expert but like thinking outside the box, you could try a pixel border around all the screen and if the mouse co-ordinates are equal or greater to the border change the state?

Im sure there's better answers and this may not work :-)

1 decade ago by quidmonkey

Attached an mousemove event to the document vs. the canvas.

document.addEventListener( 'mousemove', myFunction, false );

Take a look at ig.Input.mousemove() for how to get mouse coordinates. Then test to see if the mouse's position is within the canvas's coordinates.

1 decade ago by erfuller

I'll give that a shot, thanks.
Page 1 of 1
« first « previous next › last »