VitaZheltyakov Posted June 19, 2016 Share Posted June 19, 2016 Hey.Is there an easy way to disable the input of all objects in the scene? Link to comment Share on other sites More sharing options...
megmut Posted June 20, 2016 Share Posted June 20, 2016 If you add them all to a group, you can do... for(var i = 0; i <= myGroup.children.length-1; i++) { myGroup.children[i].input.enabled = false; } A better solution, may be to add a toggle variable to each input you wish to be toggled. Like this... this.button1 = this.add.image(0, 0, 'myButton'); this.button1.toggleInput = true; for(var i = 0; i <= this.children.length-1; i++) { if(this.children[i].toggleInput = true) { this.children[i].input.enabled = false; } } The above way will scan through the states children, and checking for a toggleInput object, if it's true, then you can change it's value. You may want to set a toggle one liner as shown here: so you don''t have to do loads of if, else's: http://stackoverflow.com/questions/11604409/toggle-a-boolean-in-javascript Hope this helps! Link to comment Share on other sites More sharing options...
VitaZheltyakov Posted June 24, 2016 Author Share Posted June 24, 2016 Solution: game.input.enabled = false; Link to comment Share on other sites More sharing options...
Dakar Posted March 21, 2017 Share Posted March 21, 2017 My solution: groupsInputEnableDisable : function (groups, state) { for (var i in groups) { groups[i].forEach(function (item) { item.inputEnabled = state; }); } }; And when I need to turn on/off some of the groups: this.groupsInputEnableDisable ([group1, group2], false); Link to comment Share on other sites More sharing options...
Recommended Posts