Jump to content

how to block a button press from going through the button to a sprite below


Recommended Posts

i have one ingame button that is used to control the game play..  normally you select the sprites (players) by clicking/touching them..  if you click on the button and there is a sprite below you also select the sprite.. i need to block this but i don't know how..


i tried to set a variable "inputBlock" to true on inputOver and to false on inputOut to check against before selecting a sprite but this does not work on mobile..  it blocks everything all the time..







Link to comment
Share on other sites


You need to set input priority for the play button.


Check this : http://examples.phaser.io/_site/view_full.html?d=input&f=input+priority.js&t=input%20priority



For example set the play button to have a higher priority (instead of the default 0 ):




oke thx..  this (above) would definitely be the best way to do this IF my sprites (the ones i don't want to be selected when pressing the button) would be inputEnabled..


in my case i rely on hitTest()  to get the objects under the mouse/finger  so this is not working..


i tried


but for some reason this blocks everything on a mobile device - so i tried:

 switchfocusbutton.onInputDown.add(function(){inputBlock=true;}); switchfocusbutton.onInputUp.add(function(){inputBlock=false;});   

which works!   i now can check against inputBlock before selecting a sprite and that's it ...    :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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