Jump to content

Game input overrides any other input


federinik
 Share

Recommended Posts

Hi everybody, I'm new in the forum as well in the html5 game developing.

 

That's my problem: I have a sprite with a handler for the onUp event:

mySprite = game.add.sprite(width, height, 'unchecked');        mySprite.inputEnabled = true;        mySprite.input.useHandCursor = true;        mySprite.events.onInputUp.add(function () {            //handling...        }, this, 0);

Some linea above, I have a listener for the game's onUp event

game.input.onUp.add(function () {            //handling...        }, this, 0);

I would like to give priority to the sprite's event instead of the game's event. What can I do?

 

Thank you

 

F.

Link to comment
Share on other sites

  • 1 month later...

Using 2.0.7. I'm a newbie.

 

I have the same problem.

Because the game input events (which I am using to detect on which tile the user clicked) are firing before the sprite events, I can't execute my game logic neatly.

 

For my current situation, I view the game input events as "canvas" events. So they are below the sprites, and because I click on the sprite, I expected the sprite events to be fired first, then the game input events.

Because it's the other way around, two things happen:

  1. game input event fires, the selected sprite moves to the position of the tile that's under the pointer
  2. enemy sprite input event fires, the selected sprite attacks the enemy sprite

If it were the other way around, I'd simply block the "move" action from happening, but now I can't reliably ascertain when the user wants to move or attack.

 

EDIT: The more I think about it, the more I feel it's probably a design issue on my end, rather than a Phaser issue. But I'm not sure.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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