valueerror Posted October 10, 2014 Share Posted October 10, 2014 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.. thx! Link to comment Share on other sites More sharing options...
j0hnskot Posted October 10, 2014 Share Posted October 10, 2014 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 ):playButton.input.priorityID=1; clark 1 Link to comment Share on other sites More sharing options...
valueerror Posted October 10, 2014 Author Share Posted October 10, 2014 oh.. this sound great but i am using hittest to find out if i clicked one of my sprites.. they have no input enabled.. so i wonder if this will work... but i could refactor my code and use input enabled sprites if this is the only way... Link to comment Share on other sites More sharing options...
valueerror Posted October 11, 2014 Author Share Posted October 11, 2014 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 ):playButton.input.priorityID=1; 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 triedswitchfocusbutton.onInputOver.add(function(){inputBlock=true;});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 More sharing options...
Recommended Posts