Skip to content

Commit fbd2de5

Browse files
Dan CoxDan Cox
authored andcommitted
Cordova 'deviceready' event check
A slightly obnoxious but necessary hack to prevent a race condition between the loading of Apache Cordova and Phaser itself. Without waiting for the 'deviceready' event, Phaser can often load first, preventing any console messages from appearing to the user. Because Cordova writes to the platform's console (via CordovaLog), it must first be loaded and signal its own 'deviceready' event before console or plugin usage can occur. Otherwise, all messages and functionality is ignored.
1 parent 6fd51e2 commit fbd2de5

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/core/Game.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
321321
{
322322
window.setTimeout(this._onBoot, 0);
323323
}
324+
else if(typeof window.cordova !== "undefined")
325+
{
326+
document.addEventListener('deviceready', this._onBoot, false);
327+
}
324328
else
325329
{
326330
document.addEventListener('DOMContentLoaded', this._onBoot, false);

0 commit comments

Comments
 (0)