8 years ago by denkle
1. Add the admob plugin to your cocoon project.
2. Add cordova.js to your index.html above your other scripts.
3. Title Screen for example.
Now, each time on the titlescreen the ad will called.
<cocoon:plugin name="cocoon-plugin-ads-ios-admob"/> <cocoon:plugin name="cocoon-plugin-ads-android-admob"/>
2. Add cordova.js to your index.html above your other scripts.
<script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="game.min.js"></script>
3. Title Screen for example.
TitleScreen = ig.Game.extend({ // ... rdy: false, init: function() { // ... if (ig.interstitial) { ig.interstitial.load(); } else { ig.interstitial = Cocoon.Ad.AdMob.createInterstitial("ca-app-pub-XXXXXXXXXXXXXXXX/NNNNNNNNNN"); ig.interstitial.on("load", function(){ ig.interstitial.show(); }); ig.interstitial.on("fail", function(){ ig.game.interstitialCall(); }); ig.interstitial.on("show", function(){ // }); ig.interstitial.on("dismiss", function(){ ig.game.interstitialCall(); }); ig.interstitial.on("click", function(){ ig.game.interstitialCall(); }); ig.interstitial.load(); } }, update: function() { // ... if (!this.rdy) { return; } // ... }, interstitialCall: function() { this.rdy = true; }, // ... });
Now, each time on the titlescreen the ad will called.