Dan1
Member
Hey everyone,
I hope you can help here. I'm having some real trouble setting up AdMob to work on android.
When I play the game on PC it works fine (without ads), but when I export the APK and run on my android device, whenever I enter the level (where I want to display the ad), it crashes the game.
What I want to achieve is a banner ad in-game and an interstitial ad when exiting to go back to the menu.
This is my code at the moment:
Level Control Object <CREATE>
Level Control Object <SOCIAL>
Back to Menu <CREATE>
Back to Menu <STEP>
Back to Menu Button <LEFT RELEASED>
Level Select Controller (Room before Control Object) <CREATE>
My understanding of this is that it would set up the ads before I load the level, then when the level is loaded, it will display them. However, it just crashes out of the game entirely with no explanation!
Any ideas what I'm doing wrong here, any help is really appreciated.
Thanks
I hope you can help here. I'm having some real trouble setting up AdMob to work on android.
When I play the game on PC it works fine (without ads), but when I export the APK and run on my android device, whenever I enter the level (where I want to display the ad), it crashes the game.
What I want to achieve is a banner ad in-game and an interstitial ad when exiting to go back to the menu.
This is my code at the moment:
Level Control Object <CREATE>
Code:
if(os_type==os_android)
{
GoogleMobileAds_LoadInterstitial();
GoogleMobileAds_AddBannerAt("---BANNER AD ID PLACED HERE---",GoogleMobileAds_Banner,0,0)
}
Code:
var _id = async_load[? "id"];
if _id == GoogleMobileAds_ASyncEvent
{
var ident = async_load[? "type"];
switch (ident)
{
case "banner_load":
if async_load[? "loaded"] == 1
{
GoogleMobileAds_MoveBanner(((abs(display_get_width()-GoogleMobileAds_BannerGetWidth()))/2)+100, 0);
}
break;
}
}
Code:
interstitial_loaded = false
Code:
if GoogleMobileAds_InterstitialStatus() == "Ready"
{
if interstitial_loaded != true
{
interstitial_loaded = true;
}
}
Code:
if interstitial_loaded = true
{
interstitial_loaded = false;
GoogleMobileAds_ShowInterstitial();
}
Code:
if(os_type==os_android)
{
GoogleMobileAds_Init("---INTERSTITIAL AD ID PLACED HERE---")
}
Any ideas what I'm doing wrong here, any help is really appreciated.
Thanks