Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more

Tech

Using Advertising Extensions

Posted by Mark Alexander on 16 May 2014

Please be aware functionality has been changed and expanded greatly in a more recent v2 of this demo which can be accessed here.

With GameMaker: Studio 1.3, extension packages for advertising providers have been introduced for the iOS and Android target modules. These advertising extension packages will gradually be introduced to all other platforms over the next few months, so in this article we will take a look at how to go about using them in your games.

Previously when adding advertising to your game you were limited to the functionality that was built in to GameMaker: Studio, which meant that you could only use what the developers felt was relevant to include. This was fine to start with, but the changing nature of the providers SDKs and the different needs of individual developers meant that this was a far from optimal way to do things, which is why the change is being made to extension packages. By making this change, any changes to the provider SDK can be added quicker, and it will permit you, the developer, to add your own functionality to the package and extend it's possibilities.

Ad provider Demos

To get started with the new system, you must first download the demo GMZ files that are available from the YoYo Games Demos feed. You can find them from the "Demos" tab of the Gamemaker: Studio welcome screen:

These demo projects are comprised of a room with some buttons and an extension package for the given provider, and you should be able to test them on your iOS or Android device immediately, since they come with YoYo Games ad-provider codes for testing (you will need to compile a final APK for Android testing, but you should be able to test from GameMaker: Studio for the iOS target). They illustrate the basic functionality for each provider, permitting you to load and display interstitial ads or banners, as well as see how the code has been structured for using them.

Note, however, that the demos do not expose all of the functionality the ad provider offers as part of their SDK. Instead they show the basic functions required to show ads, but you can easily use the SDK documentation for the provider to add your own functions to the package and extend it to cover all your needs. 

Using The Demos

As mentioned above, you should be able to create an APK or test these demos without any further setup from you, but if you wish to test your own ad IDs, you will need to change the IDs used in the Create Event of the “oControl” object common to all the demos. You may be better creating new IDs for this, as some of the providers (like AdMob, for example) have changed their SDK and web dashboard, which means that older ad IDs will no longer function with the SDK supplied in the demo.

If you want to explore the demo SDKs or wish to add extra functions to GameMaker: Studio using them, then you can edit the individual source files to include IDs or add functionality. For example, you can use test ads when using the AdMob extension package by adding your device ID to the source files in the correct place (the device ID is shown in the debug output when testing). This would be done by right-clicking on the extension package in GameMaker: Studio and selecting “Open In Explorer”, then browsing to the source files. You would then change the admob.mm file on iOS and the GoogleMobileAdsExt.java file for Android. In both cases there are lines commented out that refer to test ads which should be un-commented and the Device ID that you got from the debug output added in.

Most of the ad providers permit test ads and it is recommended that you use this feature to prevent accidental click-through for your ads which could cause problems with the provider later.

Exporting The Package For Your Games

Once you have tested the required demo file and are happy that you understand how it works and how to use the custom extension functions that it adds, you can export the extension as a GMEZ file for use in your own games.

In future updates to GameMaker: Studio it will be necessary to have first have created a Profile Certificate from the GameMaker: Studio Preferences (see the manual for further details) before you will be able to export an extension package.

However, with the current 1.3 Beta and EA versions this is not yet necessary and you simply right-click on the extension from the resource tree and select the option “Export Extension” from the options presented. This will create a GMEZ file, and this can now be added as an extension package to any other project that you are working on to enable ads.

It is important to note that if you have existing ad-calling functions from previous versions of GameMaker: Studio in your project, then they may need to be removed, or at least be changed, to call the functions used in the extension.

Basic Functions

The demos come with a number of basic functions, the most important of which we'll outline here, again using Google Mobile Ads as our example. The actual function names will change to indicate the provider being used, but the basic syntax will remain the same for all. it is worth noting that more functions may be added by the developers as time passes.

The functions in the AdMob extension are:

GoogleMobileAds_Init(bannerID, interstitialID)

- Call this function at the very start of your game to initialise the ads. The bannerID and interstitialID should be passed as strings and refer to the unique ad ID that is created when you create the ad from the AdMob console. Use an empty string “” if you do not require one of the options.

GoogleMobileAds_LoadInterstitial()

 - Call this function when you want to load an interstitial ad. If you do not call this function before trying to show an ad, nothing will be shown.

GoogleMobileAds_InterstitialStatus()

This function will return a status string which you can use to display the status of your interstitial ads. The possible return values are:

  •  “Not loaded” - No interstitial has been loaded
  • “Loaded” - The interstitial has been loaded and is ready to show
GoogleMobileAds_ShowInterstitial()

- This function will show the interstitial ad, as long as one is avialable and loaded.

GoogleMobileAds_AddBanner()

- Shows a banner ad in your game.

As you can see, the basic functions are simple to use and should be very easy to integrate into your game. 

Summary

We hope that this helps you to start integrating the new advertising packages in your games, as over time all external SDKs will be added to GameMaker: Studio in this way. It gives both you and the developers unprecedented flexibility when using them and updating them, and it also means that for the first time ever, you can have more than one ad provider active in your game at a time. If you want Ad Colony interstitials as well as Mo Pub banners, then you can do this now, since each package comes with it's own uniquely named functions,

Back to Top