• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Switch ON/OFF the AD banner when enter/exit from PAUSE

A

ArtCode

Guest
Hello folks!
I'm trying to insert some ADs in my game! Well I want them to appear only when the game goes in PAUSE state.
To this moment the AD does appear when I'm entering in the state of PAUSE but when I resume the game the AD doesnt go off... it stays there :/
Here is my code:
The AD is handled by another OBJECT which is the PAUSE BUTTON ...

obj_Pause_Button
Mouse_Left_Pressed EVENT:
Script 1
Code:
global.isPaused = !global.isPaused;
// Some other code is here but its not important
Script 2
Code:
if(global.isPaused){
    instance_create(0,0,obj_BannerAd);
}
if (!global.isPaused){
        with(obj_BannerAd) instance_destroy();
}
Than I created 2 objects for the ADs
obj_LoadAds
START GAME Event
Code:
GoogleMobileAds_Init("ca-app-pub-3940256099942544/6300978111");
obj_BannerAd
CREATE Event
Code:
GoogleMobileAds_AddBannerAt("ca-app-pub-3940256099942544/6300978111", GoogleMobileAds_Banner, 0, view_yview + 1210 );
This one is for creating a Banner AD after the AD is loaded. Don't worry, that AD Id is the TEST from the AdMob website.

The scripts are simple but I dont understand why the BANNER doesnt destroy if I say so...
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Ads aren't attached to objects so destroying the object doesn't destroy the ad. There should be a remove function in the extension for this. Alternatively, just create the add on game start and use the position extension functions to move it on and off screen. For example if you are showing the add at the top of the screen, setting the position to -500 or something will move it outside the GUI view and invisible to the player. I found that simply moving the ads on and off screen as required was a better solution than creating/destroying them all the time.
 
A

ArtCode

Guest
Thanks a lot for your advice! I was in doubt if AdMob will let me do a such thing... because you are putting an AD that is not visible for the most part of the game. But after your answer I think this will be ok! ahah :)
 
U

Uberpink

Guest
a little question,,, for you to make the banners show, -do you not use the code GoogleMobileAds_UseTestAds(true,"YOUR DEVICE ID" ? //phone id
 
Top