Tom Atom Posted June 4, 2015 Share Posted June 4, 2015 Hi, I have following problem with game embeded in iframe on iOS (tested on iPad): 1) game starts, everything ok, 2) I click outside of the game - game stops (onBlur() and onPause() is called), 3) i click the game in iframe again, but it does not resume nor gets focus. I have this problem only on iPad. On desktop it gets focus (onFocus()) and is resumed (onResume()). Any help with similar issue? Link to comment Share on other sites More sharing options...
Tom Atom Posted June 4, 2015 Author Share Posted June 4, 2015 I tried minimal game from Emanuele Feronato's site: http://www.emanueleferonato.com/2015/01/02/html5-swipe-controlled-sokoban-game-made-with-phaser-step-2-adding-keyboard-controls-and-unlimited-undos/ I put it into iframe and problem was not there. I tried to switch underlaying Phaser version to Phaser 2.3.0 and problem is back. So, currently I know, that problem is with Phaser 2.3.0 and Phaser 2.2.2 is working. Unfortunately, for my latest game I need Phaser 2.3.0. Link to comment Share on other sites More sharing options...
Tom Atom Posted June 4, 2015 Author Share Posted June 4, 2015 After half day spent with this issue I finally found it! In boot() method of Phaser.Game object there is new piece of code (compared to Phaser 2.2.0): if (window['focus']) { if (!window['PhaserGlobal'] || (window['PhaserGlobal'] && !window['PhaserGlobal'].stopFocus)) { window.focus(); } } In release notes (part Updates) I found this text: "When the Game first boots it will now call window.focus(). This allows keyboard events to work properly in IE when the game is running inside an iframe. You can stop this from happening by setting window.PhaserGlobal.stopFocus = true (thanks @webholics #1681)" Unfortunately, this breaks game running in iframe on iOS. Whenever you click outside of the game iframe, you never get focus back and game is stuck! So, it is neccessary to add this global object to game to prevent call to window.focus():var PhaserGlobal = { stopFocus: true} Link to comment Share on other sites More sharing options...
Recommended Posts