Jump to content

iOS iframe focus problem

Tom Atom

Recommended Posts



 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

 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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...