Lizard Posted October 22, 2016 Share Posted October 22, 2016 Hello everyone! As shown in this example http://phaser.io/examples/v2/input/out-of-game-mouse-up Mose up is firing when you move your mouse with holded button out of canvas. So the question is here any ways to disable this firing? Best regards hdouss 1 Link to comment Share on other sites More sharing options...
Taggrin Posted October 25, 2016 Share Posted October 25, 2016 I don't think you can disable it directly, as there is no way for the game to find out where the pointer moved once out of the canvas. Someone can correct me if wrong . One solution I can think of is that upon calling onUp() to check whether the mouse is still within the range of the game. For the example that would mean: game.input.mousePointer.x should be > 0 and < 800. game.input.mousePointer.y should be > 0 and < 600. Link to comment Share on other sites More sharing options...
hdouss Posted October 25, 2016 Share Posted October 25, 2016 I would also have a question about onUp firing if you move out the cursor/finger out of the button/sprite (but still inside the canvas). Should I also check if the pointer coordinates are stille inside button bounds ? Link to comment Share on other sites More sharing options...
drhayes Posted October 25, 2016 Share Posted October 25, 2016 Yeah, you probably should. Most GUI systems work like that, i.e. they let you click in the button, move outside the bounds of the button, release the mouse and it won't click the button. I don't remember the *exact* call, but you have to re-check that your pointer is still inside the bounds of whatever it is that's clickable. "sprite.input.checkboundsSprite" maybe? I forget. Link to comment Share on other sites More sharing options...
Lizard Posted October 25, 2016 Author Share Posted October 25, 2016 For checking is pointer still on sprite/button you can use third argument of onInputUp. It is sent three arguments: {any} The Game Object that received the event. {Phaser.Pointer} The Phaser.Pointer object that caused the event. {boolean} isOver - Is the Pointer still over the Game Object? But in case when sprite near canvas border it could trigger wrong onInputUp event, when pointer with holded button will move out of canvas from sprite. It you will look at pointer coords at this moment it will be inside canvas and third argument of onInputUp will be true. hdouss 1 Link to comment Share on other sites More sharing options...
hdouss Posted October 25, 2016 Share Posted October 25, 2016 Thanks Lizard. Exactly what I was looking for ! Link to comment Share on other sites More sharing options...
Recommended Posts