Zampano Posted December 6, 2017 Share Posted December 6, 2017 Hey there, I'm trying to get a key to always call a certain function, regardless of which state my game is in. At the moment, my code is this: var escKey = null BasicGame.Boot = function (game) { //... }; BasicGame.Boot.prototype = { init: function () { escKey = game.input.keyboard.addKey(Phaser.Keyboard.ESC); escKey.onDown.add(function(){console.log("esc")}, game); } And so on. escKey stays defined in all states, but onDown doesn't trigger. If I move the two lines within init to a state, I can use ESC in that state, but not in any state after that. Is there a way to do this? Link to comment Share on other sites More sharing options...
n7pankake Posted January 11, 2018 Share Posted January 11, 2018 I believe you can Preload the variable in lets say state 0 and then use it on any other state. Link to comment Share on other sites More sharing options...
samme Posted January 11, 2018 Share Posted January 11, 2018 https://photonstorm.github.io/phaser-ce/Phaser.Input.html#resetLocked Link to comment Share on other sites More sharing options...
Recommended Posts