Displaying Interstitial Ads through AdMob in Game Maker Studio

A quick note on Interstitial Ads in Game Maker using Admob. Interstitial ads are handled mainly the same as regular banners, only with a couple of minor slight modifications. Go ahead and create the new Intersitial ad on AdMob’s website and copy your Ad Unit ID code. As before, paste this code into any one of the 4 keys for Admob under the advertising tab in the Global Games Settings window.

Now, with banners, we’d have to enable them and move them to an appropriate location. Not so with interstitial ads. First of all, they’re not enabled by the usual ads_enable(x,y,key) command. And second, being that they’re interstitial and fullscreen, we have no control over the position of the ad onscreen. So then, how do we enable an interstitial ad? Simple. With just one line of code:

ads_interstitial_display();

I’m not entirely certain the specifics behind calling that function, as you don’t pass it any arguments. Say you were to have multiple interstitial ads entered in individual keys in GM – AdMob would treat them separately as far as impressions and clicks go, correct? So when Game Maker displays an interstitial ad, which one does it choose? This isn’t a major concern for me, because I don’t see myself using separate interstitial ads in one app.

You’ll notice though, calling that function might not always work. In fact, one time you might try it and it’ll work perfectly, and the next time, in a different room, you’ll notice that absolutely nothing happens. Why is this? After quite a bit of frustration, I realized: calling the ads_interstitial_display() function isn’t like enabling a banner ad. When you call the function, it doesn’t just enable the ad and it’ll finally display it when it’s loaded and good to go. No. When you use the ads_interstitial_display() command, it attempts to launch the interstitial ad that very step if it’s available. And if it’s not available? You’ll have to call the function again when it is. Enabling ads is more of a boolean, and interstitial ads are more of a one-time function. Fortunately, Game Maker has a function built in that allows us to check if the interstitial ad is loaded and good to go:

ads_interstitial_available()

So very easily, in the step event, we could do something as follows:

if (!displayed_interstitial_ad)
{
     if (ads_interstitial_available())
     {
     displayed_interstitial_ad = 1;
      ads_interstitial_display();
    }
}

The “displayed_interstitial_ad” is just a variable/boolean I created that we set to 1 after we display the ad so it won’t constantly display it over and over again when the user clicks out. I found that it takes about 3 seconds to load the ad after you launch your app. I was attempting to display the interstitial ad within a second or two after my app launched, and of course, it didn’t work. So… give it some time to looaaaad, man.

With that being said, I can now implement banners and interstitial ads in my app! 

 

4 thoughts on “Displaying Interstitial Ads through AdMob in Game Maker Studio

  1. hello sir, could you give me a tutorial how to add interstitial admob on game maker studio. I follow all tutorial on youtube but none of them could shown then interstitial ads. sorry for my bad english and thanks in advance

    1. Hey there Julian – apologies for the late response. Game Maker has actually changed the way ads are displayed since I wrote this post about 2.5 years ago. I actually jumped ship and work mainly in Unity now so I’m afraid I wouldn’t be able to help you there. Hope you can find some information.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s