我需要帮助让游戏在正确的地方运行,在 onDeviceReady 内。这是我的游戏目前的格式。我不认为游戏运行良好,除非我改变它。主要是我不确定如何确定变量的范围并在设备就绪后设置它们。太感谢了。
var cocoon_active = typeof(Cocoon) === 'object'
var one, two, three; // ...
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
if (cocoon_active) {
// ...
}
// FIXME CANVAS+ CODE RUNS HERE
}
window.onload = function() {
game = new Phaser.Game(game_width, game_height, Phaser.AUTO, '');
game.state.add("play_game", play);
game.state.start("play_game");
}
var play = function(game){}
play.prototype = {
preload: function() {},
create: function() {},
update: function() {},
render: function() {}
} // end prototype
function a() {}
function b() {}
function c() {} // ...