mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
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:
parent
6fd51e29b2
commit
fbd2de5b23
1 changed files with 4 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue