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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.