totallybueno Posted August 29, 2017 Share Posted August 29, 2017 Hi there, everytime I have to make a game that pauses when the canvas loses the focus (jquery blur()) I struggle with lines and lines of stupid lines of javascript and I´m pretty sure there´s something simpler than my way to do that. I have a normal sprite on the game that pauses/unpauses the game, and I would like to do exactly the same when the canvas focus/blur... how do you guys handle this? Link to comment Share on other sites More sharing options...
Alexalten Posted August 29, 2017 Share Posted August 29, 2017 Hi, in Phaser's examples there is an interesting script about the "pause option": http://phaser.io/examples/v2/misc/pause-menu personally (this is only my preference) I use a simple flag to pause the game: in the "update" section of the game, when the flag is 1, then check collisions, move sprites using buttons, check when keyboard is pressed, etc.etc. when the flag is 2, then "make something else" (like a message on screen), so all previous action are "freezed" everithing come to normal when the flag come back to 1 but, remember, this is only my personal preference. I suppose there are other options. Bye, Alex Link to comment Share on other sites More sharing options...
totallybueno Posted August 29, 2017 Author Share Posted August 29, 2017 I don´t have any problem pausing the game, that´s ok, the problem I have (not really related with Phaser) is how to deal with the canvas when it loses/gains focus... Link to comment Share on other sites More sharing options...
Recommended Posts