I need help getting the game to run in the right place, inside onDeviceReady. Here is how my game is formatted as of now. I don't think the game runs well unless I change it. Mainly I'm not sure how to scope the variables and set them after deviceready. Thank you so much.
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() {} // ...
Do you think the game doesn't run well, or do you actually get an error or black screen? Does the console give any error message when you try it in the CocoonJS launcher app?
The way I added some code before starting-up CocoonJS in my game was like this. I added something like the code below into a separate script and included that as source in the main index.html:
And I added the phaser startup code inside the
<body>of the mainindex.html