Funding Your XNA Game With Adverts

[Update: It’s becoming harder to support Ads on Windows 7 Phones. In Sept 2013, Google dropped ad support completely.]

Gunther Fox (one of our seniors in Game Programming) has been exploring the use of advertising as a revenue stream for his XNA based game projects on the Windows 7 Phone.

Gunther has supplied the following information for others looking to include advert support into their own projects.

Placing an Advert in a Windows Phone XNA game can be accomplished in a few simple steps.

  • The developer must fist add a reference to the Microsoft.Advertising.Mobile.Xna library to their project.
  • This will allow them to declare an ‘AdGameComponent’ and a ‘DrawableAd’:
  • static AdGameComponent adGameComponent; static DrawableAd bannerAd;

  • They must then initialize the AdGameComponent in Game1’s constructor:
  • AdGameComponent.Initialize(this, "test_client"); adGameComponent = AdGameComponent.Current; Components.Add(adGameComponent);

  • Finally, they need to load their DrawableAd in the ‘LoadContent’ function
  • bannerAd = adGameComponent.CreateAd("Image300_50", new Rectangle(0, 20, GraphicsDevice.Viewport.Bounds.Width, 120));

Read more on the MSDN.

Thanks for sharing.

Leave a Reply