JoseDu Posted February 24, 2014 Share Posted February 24, 2014 Hi everyone,is there any way how to detect and pause game when iOS (7) device is locked?When I lock my device during the game, it still runs on background. It also happens when I leave browser (Safari, Chrome) with the home button and then resume. Everything works fine on Android devices or when I switch tabs on iOS. I have "disableVisibilityChange" set to "false" and pausing the game with the "this.game.onPause" event.You can play the game on: http://brainie.strangevillage.com/brainie_test/ Thanks! Link to comment Share on other sites More sharing options...
rich Posted February 25, 2014 Share Posted February 25, 2014 Just to say that I did a huge load of work on improving the way the visibility api is handled today and this is now working as expected across desktop and mobile. I've tested on iOS7 and it's pausing properly when you jump between tabs, close to the home screen or the iPad locks. This is all in the 1.2 branch right now and will be released in the next update. If you needed to you could probably extract the new code from core/Stage.js and merge with the current version of Phaser. Link to comment Share on other sites More sharing options...
JoseDu Posted February 25, 2014 Author Share Posted February 25, 2014 Great! Thanks a lot! Link to comment Share on other sites More sharing options...
pippinbarr Posted March 12, 2014 Share Posted March 12, 2014 Hey there - just want to continue this topic as I'm trying to do some onPause/onResume stuff right now and I'm not getting the behaviour of onPause triggering when I go to the home screen or lock the device (iPhone 5, iOS 7.1). Works like a dream on switching tabs in Mobile Safari, and works perfectly in all situations I could think of for laptop browser (Chrome). Am I missing something, or is this just in flux in 1.2? Link to comment Share on other sites More sharing options...
rich Posted March 12, 2014 Share Posted March 12, 2014 I've not touched the code for this (in 1.2) since I posted that message above. It still appears to be working as expected here, although I've not updated to iOS 7.1 yet so will do that now. But I'm seeing the correct things log out in Safari. Link to comment Share on other sites More sharing options...
pippinbarr Posted March 12, 2014 Share Posted March 12, 2014 Oh yeah? Hmmm, that's odd then. It may be something with me as I see I'm not getting the trigger on an iPad 2 running OS 7.0.5 (I think - certainly pre 7.1) either... so maybe it's my code. So all I'm doing is setting visibility checking in Boot.jsthis.stage.disableVisibilityChange = false;and then in the create function in my Game.jsthis.game.onPause.add(this.onGamePause,this);this.game.onResume.add(this.onGameResume,this);And this triggers from all forms of focus loss on my laptop's browser, and for tab changes in mobile Safari, but never for screen lock or for hitting the home button on my iPhone 5 or my iPad 2. Am I just doing something stupid? Would love it if I were! (For now, by the way, my particular need is also met by the usual thing off setting a looping check to see whether more time has elapsed than "should have" because the page has been put to sleep by the OS/Browser.) Link to comment Share on other sites More sharing options...
Recommended Posts