bobonthenet Posted April 5, 2017 Share Posted April 5, 2017 I have been able to successfully build and run my game on mobile using cocoon.io but now I want to put in some ads. Unfortunately, I've been unable to get that working on my own. within the boot state I have the following code boot.init = function () { ... this.game.device.whenReady(function(){ if(this.game.device.cordova) { if(typeof Cocoon.Ad.AdMob !== 'undefined' && Cocoon.Ad.AdMob) { this.setupAdmob(); } } }) }; boot.setupAdmob = function() { var admobSettings = {}; admobSettings = { interstitial: 'my-admob-id' }; Cocoon.Ad.AdMob.prepareInterstitial({ adId: admobSettings.interstitial, autoShow: false, isTesting: true }); } then within the game state, I have the following game.gameOver = function () { Cocoon.Ad.AdMob.showInterstitial(); this.ball.body.velocity.setTo(0, 0); this.introText.text = 'Game Over!'; this.introText.visible = true; this.time.events.add(Phaser.Timer.SECOND * 4, function() { this.state.start('game'); }, this); }; I also have cordova.js included in my index.html, I think that is all I should need. The game state order goes from menu > boot > preloader > game. It is displaying the menu but won't go anywhere beyond that. I'm not sure if it is the menu itself that is frozen or if it is hanging up in boot or preload before getting to the game state. Because this is on my phone I don't see any debug errors or anything. It is just frozen. Can anyone see what I am doing wrong? Link to comment Share on other sites More sharing options...
bruno_ Posted April 5, 2017 Share Posted April 5, 2017 You have to debug it to see errors in the console, if it's running on android try to use adb. adb logcat -s chrome You can also use vorlon.js to inspect it. bobonthenet 1 Link to comment Share on other sites More sharing options...
bobonthenet Posted April 5, 2017 Author Share Posted April 5, 2017 26 minutes ago, bruno_ said: You have to debug it to see errors in the console, if it's running on android try to use adb. adb logcat -s chrome You can also use vorlon.js to inspect it. I have had horrible luck figuring out how to debug once the game is on mobile. I have never heard of vorlonjs, though I'm excited to give that a try. Thanks, I'll report back with what I find. Link to comment Share on other sites More sharing options...
espace Posted April 5, 2017 Share Posted April 5, 2017 by me this works function main(){ //your code,states and ads ) main() document.addEventListener('deviceready',main,false) Link to comment Share on other sites More sharing options...
bobonthenet Posted April 6, 2017 Author Share Posted April 6, 2017 I got it figured out! Vorlon.js for the win! There were a handful of issues. The example I used to set up my interstitial ad was out of date so that whole bit was wrong. None of the methods I used to set up or display the ad were valid. bruno_ 1 Link to comment Share on other sites More sharing options...
Recommended Posts