Jump to content

Sprite with .inputEnabled=true blocking other input


tomdanvers
 Share

Recommended Posts

Hi,

I'm having an issue with a game ui I'm working on.

 

I set up a number of sprites as buttons for a UI. They sit to the left of the screen and have event listeners associated with their onInputUp signals which fire correctly.

 

Later in the user journey I create another sprite that sits below these interactive sprites and takes up the full size of the screen. This new sprite is also interactive (event listeners associated with both onInputUp and onInputDown fire correctly).

 

HOWEVER, the new sprite blocks input events for the original sprites event though it visually sits below the full screen sprite.

 

Does anyone have any idea what I'm doing wrong? I'm guessing I'm missing something vital about the way Phaser handles z-index and inputs?

 

Interestingly if I .destroy() the full screen sprite the original sprites still remain unresponsive... weird!

 

Thanks in advance!

Link to comment
Share on other sites

Hi Rich,

Thanks for the answer, I really appreciate it.

 

It ended up that I was doing something stupid.

I needed to store the position of a pointer object over time (to achieve a line drawing affect), I foolishly overwrote the .move function of the pointer object in the hope that I'd effectively get 'move' events. It worked but in the process all the Phaser code that fired 'on move' was wiped which caused all kinds of chaos  :rolleyes:

 

I changed the object to check the pointer position in the update() method of the sprite in question and low and it worked.

Thanks,

Tom

Link to comment
Share on other sites

If doing an art package style thing then I would suggest using Input.addMoveCallback to get a smoother result than polling pointer coordinates in an update.

 

Also the Input manager has a coordinate history feature built in btw :) (Input.recordPointerHistory) but I wouldn't use this for a drawing app personally.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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