Seth August 8th, 2016 Hello, I am trying to incorperate Admob into my wade game. I have read a ton of documentation on Admob and everything points to using either Eclipse or Android Studio to use Admob. Iv'e created all neccesary accounts and a project in Android Studio. What I don't understand is how I tell Admob where to put the ads in my game? Does Admob get compiled into the apk file? Can I download my wade source and use Android Studio to compile it, along with Admob? I am just really unsure how I would go about doing this. Any info on the subject would be most welcome, Thanks!
I found this thread, but it is mostly about how to place ads: http://clockworkchilli.com/forum/thread?id=Wade_with%20admob___306
Gio August 10th, 2016 Yes, even though I haven't used AdMob in an Android project, my understanding is that you can just download the source code of your project from the wade editor, open that in Android Studio and follow Google's instructions for adding AdMob to it.
I think there are many ways of doing it, but at least 2 easy ways:
- Editing index.html, put your game inside an iframe, and create a div somewhere else that contains your AdMob ads
- Leave some space say at the bottom of the screen when you design your game, and place an absolutely-positioned div that ends up there on top of your game
Seth August 11th, 2016 Hi Gio, thanks for the reply. I am now using intel xdk with cordova to compile source and ad AdMob. I have added the correct plugins and edited my index.html file. My problem is I want to open an interstitial ad everytime that hiddenobjects.js is called, or alternativly at the end of hiddenobjects.js. So here is what I've done:
HiddenObject = function()
{
this.targetObject = '';
this.targetSprite = '';
this.movementSpeed = 1000;
this.rotationSpeed = 10;
this.onMouseDown = function()
{
var t = wade.getSceneObject(this.targetObject);
if (t && this.movementSpeed)
{
var ts = t.getSpriteByName(this.targetSprite);
if (ts)
{
this.owner.moveTo(ts.getPosition().x, ts.getPosition().y, this.movementSpeed);
if (this.rotationSpeed)
{
this.owner.setAngularVelocity(this.rotationSpeed);
}
this.owner.getSprite(0).setVisible(false);
var s = this.owner.getSprite(1);
s.setVisible(true);
s.bringToFront();
var time = wade.vec2.length(wade.vec2.sub(this.owner.getPosition(), ts.getPosition())) / this.movementSpeed;
s.setDrawFunction(wade.drawFunctions.fadeOpacity_(1, 0, time, s.getDrawFunction()));
}
}
};
this.onMoveComplete = function()
{
var t = wade.getSceneObject(this.targetObject);
if (t)
{
var ts = t.getSpriteByName(this.targetSprite);
if (ts)
{
ts.setImageFile && ts.setImageFile(this.owner.getSprite(1).getImageName());
}
}
wade.removeSceneObject(this.owner);
wade.playAudioIfAvailable("woosh.ogg");
if (!wade.getSceneObjects('objectToFind', true).length)
{
// game is over, do something here
wade.getSceneObject('greatjob').setVisible(true);
wade.getSceneObject('nextbutton').setVisible(true);
wade.playAudioIfAvailable("tada.ogg");
// This is where I want an AdMob ad
AdMob.isInterstitialReady(function(isready){
if(isready) AdMob.showInterstitial();
});
}
};
};
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0, minimal-ui"/>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Curious George: Hidden Objects</title>
<script>
//********************
// Start of Admob code
//********************
var admobid = {};
if( /(android)/i.test(navigator.userAgent) ) {
admobid = { // for Android
interstitial: 'ca-app-pub-4291367490811031/7059221702'
};
} else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
admobid = { // for iOS
interstitial: 'your iOS admob ad unit id'
};
} else {
admobid = { // for Windows Phone
interstitial: 'your windows phone admob ad unit id'
};
}
//
function initApp() {
if (AdMob) {
AdMob.createinterstitial({
adId : admobid.interstitial,
autoShow : false
});
}
}
</script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="AdMob.js"></script>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="wade.js"></script>
<script>
$(document).ready(function()
{
wade.init('app.js');
});
</script>
</head>
<body>
<div id="container" style="border:0; width:800px; height:600px;">
<div id="wade_main_div" width="800" height="600" tabindex="1">
</div>
</div>
</body>
</html>
App = function()
{
// this is where the WADE app is initialized
this.init = function()
{
// load a scene
wade.loadScene('menu.wsc', true, function()
{
function onAppReady() {
if( navigator.splashscreen && navigator.splashscreen.hide ) { // Cordova API detected
navigator.splashscreen.hide() ;
}
// init admob
initAdMob();
}
document.addEventListener("app.Ready", onAppReady, false) ;
});
};
};
This is where I got most my info: https://github.com/floatinghotpot/cordova-admob-pro/wiki/02.-How-to-Use-with-Intel-XDK
Its not working, not sure where I went wrong.
Gio August 12th, 2016 Hi Seth
I think I understand what you're trying to do, but could you explain in what way exactly it is not working? Do you get any errors in the console?
Seth August 12th, 2016 Zero errors, everything still runs fine. But the ads don't show
Gio August 15th, 2016 So is it possible that in this line here
if(isready) AdMob.showInterstitial();
isready is never true?
I would add console.log(isready) just above that, and it would also be interesting to see what happens if you manually run that code from the console
Seth August 15th, 2016 OK, Ill give it try. How do I run that code through manually though? And just to be clear, I'll add it like this:
{
// game is over, do something here
wade.getSceneObject('greatjob').setVisible(true);
wade.getSceneObject('nextbutton').setVisible(true);
wade.playAudioIfAvailable("tada.ogg");
// This is where I want an AdMob ad
console.log(isready)
AdMob.isInterstitialReady(function(isready){
if(isready) AdMob.showInterstitial();
});
}
};
};