Mattias Posted November 7, 2013 Share Posted November 7, 2013 So, I have a button which I take the mouse coordinates from when it is pressed down on, then you move the mouse and release. The problem now is that if I release the mouse outside of the button area, the onInputUp callback gets skipped. I need to get the mouse coordinates from the released position to calculate which way the mouse went, and after that move the button 100px in that direction. I can't do that if the onInputUp callback gets skipped if you are outside of the button area when you release the mouse button. Is there another way to accomplish this? Link to comment Share on other sites More sharing options...
rich Posted November 7, 2013 Share Posted November 7, 2013 Add an up listener to the game itself. Then when you click down on the button set a flag somewhere, and when you next hear an up event you can do your calculation. Link to comment Share on other sites More sharing options...
Mattias Posted November 7, 2013 Author Share Posted November 7, 2013 So, I have a block class extending Phaser.Button (Everything written in CoffeeScript). I remove the onUp callback and the onInputUp event from it and add one to the create method where I create a grid of 8x8 "buttons".Now, if I set a flag on the object when I press down on it, do I loop through all these objects on the onInputUp event and check for the flag? then execute a method of choice for that object and reset the flag? Just don't want to do anything stupid and create a slow game. Link to comment Share on other sites More sharing options...
Mattias Posted November 7, 2013 Author Share Posted November 7, 2013 Ok, this is how I solved it: onDown inside object, set an object flag to true. In the game, in the create method, create an input.onUp listener. Then in the callback, this one line: @theGroupWithObjectsFromTheCreateMethod.callAll 'objectMethod' Next up was to just have the method on the object itself check if the object flag was set to true, if so continue and do the calculations, and lastly disable the flag again. Link to comment Share on other sites More sharing options...
rich Posted November 8, 2013 Share Posted November 8, 2013 I'm glad you solved it because my CoffeeScript knowledge is a little bit less than zero. Link to comment Share on other sites More sharing options...
Recommended Posts