Game Development Reference
In-Depth Information
Let's begin loading an ad right away. On another new line in the create event of the player,
add the
GoogleMobileAds_LoadInterstitial
function by loading the ad as
early as possible. This means the ad has more time to load before actually being shown.
We are going to display the ad when the player dies, so in the collision event with the en-
emy object, we need to add a new line before the
game_restart
function and then type
the
GoogleMobileAds_ShowInterstitial
function. To load a new ad, simply
use the
GoogleMobileAds_LoadInterstitial
function again after displaying the
ad.
Now, when the game starts, the ad extension is initialized and we begin loading an inter-
stitial ad. When the player dies, as long as an ad has loaded, it will be displayed to the
user. Export the game as an Android application and install it on any Android phone or
tablet to test the ads.
Ad revenue varies for each service; in order to find out how much you are earning, visit
the AdMob website.