Jump to content

Button onInputUp


Mattias
 Share

Recommended Posts

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

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...