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.
This commit is contained in:
Dan Cox 2014-08-21 00:11:41 -04:00
parent 6fd51e29b2
commit fbd2de5b23

View file

@ -321,6 +321,10 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
{
window.setTimeout(this._onBoot, 0);
}
else if(typeof window.cordova !== "undefined")
{
document.addEventListener('deviceready', this._onBoot, false);
}
else
{
document.addEventListener('DOMContentLoaded', this._onBoot, false);