User Tools

Site Tools


proton:admanager

Meet the AdManager

These days, it isn't enough to just write a game. You need to be trendy and monetize it as well.

This could mean displaying ads for a third party or your other games (Chartboost, Tapjoy), offering incentives and point systems (Tapjoy), tracking installs and what menus the player used and stuff like that (Flurry), or making money by adding buttons that open up third party stores and things. (Startapp, Hooked)

Some features of the AdManager:

  • Provides a neat plug-in like system to add new Ad systems
  • Abstracts control of the Ad systems so the same code works on Android/iOS/etc
  • Handles the low level hooks/quirks of each Ad system and the integration with the native system
  • Gives sigslot callballs for things like when points are awarded to a player in Tapjoy
  • Draws a fake rectangle ad overlay when testing in Windows/etc, so you can experiment with ad placement without really running on a device - this emulation of ad-systems on systems they don't really support help during development and debugging.

The RTAdTest example shows this in action, although it's a little hairy to get compiling because it uses EVERY ad system we support at once, disable them as needed to make it easier to get going.

How to add AdManager to an existing project

  • Add /shared/Manager/AdManager.cpp to your project
  • Add /shared/Ad/AdProvider.cpp to your project (why isn't AdManager in the /Ad directory? Legacy thing…)

Add the following after the other include's at the top your App.h

#include "Manager/AdManager.h"

Add the following to your App class in App.h:

//add this App member function (should be public)
AdManager * GetAdManager() {return &m_adManager;}

//add this App member variable (should be private)
AdManager m_adManager;

Add the following code in App::Init() in your App.cpp file

//add this after the if (!BaseApp::Init()) return false; statement
m_adManager.Init();
//Later, this where we'll init and add the real ad systems to the AdManager

In App::Update, add this under the existing BaseApp::Update() statement:

m_adManager.Update();

In App::Draw, add this under the existing BaseApp::Draw() statement:

m_adManager.OnRender();

If your App is currently not already over-riding virtual void OnMessage (Message &m ), well, you'll need to add this to your App class, otherwise just plug in the m_adManager part:

void App::OnMessage( Message &m )
{
	m_adManager.OnMessage(m); //gives the AdManager a way to handle messages
	BaseApp::OnMessage(m);
}

//and in your App.h, add this to the App class if it's not already there:
virtual void OnMessage(Message &m);

That's it! Now you should be able to run your app and.. well, the AdManager won't actually do anything other than send “AdManager initted.” to the log. To actually ad some ad providers with real functionality, see the main proton page, there are links to the various ad providers.

proton/admanager.txt · Last modified: 2012/07/06 02:49 by seth