Sunday, March 27, 2011

Windows Phone 7 XNA Games advertising

My earlier post Windows Phone 7 Silverlight, Adcontrol step by step, tricks and issues was mainly about admanager on WP7 Silverlight.

To implement admanager in XNA games, especially when you use XNA Gamestatemanagement sample Game State Management

Insert the following code in the GameplayScreen.cs file LoadContent method.

Guide.SimulateTrialMode = true;
if (Guide.IsTrialMode)
// adManager = new AdManager(this.ScreenManager.Game, "test_client");
adManager = new AdManager(this.ScreenManager.Game, "applicationid");
adManager.TestMode = false;

// Create a banner ad for the game
// bannerAd = adManager.CreateAd("Image300_50", new Rectangle(0, 700, this.ScreenManager.GraphicsDevice.Viewport.Bounds.Width, 120), RotationMode.Manual, false);
bannerAd = adManager.CreateAd("unitid", new Rectangle(0, 700, this.ScreenManager.GraphicsDevice.Viewport.Bounds.Width, 120), RotationMode.Manual,false);



When you want to test it with the testad set adManager. TestMode true, uncomment the test_client admanager constructor and comment out the applicationid admanager contructor.

When you want to test with real ads, set adManager.TestMode false, comment out adManager test_client method and uncomment adManager applicationid constructor.

applicationid and unitid Identifies the application and is assigned to you during the publisher registration process.

Interesting discussion on this in this thread in which I participated!Where to insert the admanager in Gamestatemanagment sample

1 comment:

  1. More info about the Microsoft Ad SDK and others for XNA Games can be found here: