tidelake Posted April 29, 2016 Share Posted April 29, 2016 Hello, I learned I have to run the Canvas+ code on deviceready for Cocoon. I'm not sure how to change my source around to get it right. Here's how my file is formatted right now. Somehow I need all the variables scoped into the deviceready event, so I can use the plugins during the game. Thank you. 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() {} // ... Link to comment Share on other sites More sharing options...
icp Posted April 30, 2016 Share Posted April 30, 2016 This is what I am using right now for the android status bar plugin: document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { StatusBar.hide(); } After this you can add the rest of your code: 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 VitaZheltyakov 1 Link to comment Share on other sites More sharing options...
tidelake Posted April 30, 2016 Author Share Posted April 30, 2016 I'm confused. I'm not sure if my game is using the Cavas+ library if my game loads before deviceready. The dev app console doesn't say "Created Namespace: CanvasPlus" as it does for Webview+ and others. Link to comment Share on other sites More sharing options...
purplecabbage Posted May 1, 2016 Share Posted May 1, 2016 I have been doing this, assuming cordova.js is included before your own js code. var startEvent = "DOMContentLoaded"; if(window.cordova){ startEvent = "deviceready"; } document.addEventListener(startEvent,function() { // ... }); This allows the same code to work in and out of a cordova container. Link to comment Share on other sites More sharing options...
icp Posted May 1, 2016 Share Posted May 1, 2016 17 hours ago, tidelake said: I'm confused. I'm not sure if my game is using the Cavas+ library if my game loads before deviceready. The dev app console doesn't say "Created Namespace: CanvasPlus" as it does for Webview+ and others. What do you mean by not being sure? Just wrap your app with Canvas+ or open the project files with Canvas + option from the dev app. tidelake 1 Link to comment Share on other sites More sharing options...
Recommended Posts