bobonthenet

Help with Cocoon.io Admob

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.