Jump to content

Help with Cocoon.io Admob


bobonthenet
 Share

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?

Link to comment
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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...