Jump to content

game.input.onDown VS mySprite.events.onInputDown


lukaMis
 Share

Recommended Posts

Hi

 

I have game.input.onDown and mySprite.events.onInputDown listeners in game. 

 

I add listener for on game later than on sprite but listener for game triggers before event on sprite. 

Is there any way i can manipulate event flow. 

 

Similar to what we have in DOM events (

event.target

event.currentTarget

event.preventDefault()

event.stopPropagation()

)

 

Can i stop event in game listener (if sprite was clicked too) or force event to trigger on sprite first under some condition?

 

 

Link to comment
Share on other sites

the event that is fired with the inputDown event contains info of which element was pressed you could check if the object launching the event is the global-game or your sprite and if its not the correct one do 

return false;
Link to comment
Share on other sites

@MichaelD

Do you have an example perhaps? 

 

I only get 

target: canvastargetObject: null
from event on game listener. Even if i click on mySprite. 
There is no reference what object lies beneath.
And just a side note game.input.onDown and mySprite.events.onInputDown have different callback functions. 
 
Code: 
this.pauseButton.events.onInputDown.add(this.pauseGame, this);this.game.input.onDown.add(this.fireButtonDown, this);
Link to comment
Share on other sites

  • 1 year later...
 Share

  • Recently Browsing   0 members

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