Adding Advertisment Support

Jul 30, 2011 at 11:28 PM

Is there quick and painless way to add xna advertisment control in gameplay?

Coordinator
Jul 31, 2011 at 12:55 AM

Microsoft Ad Control.  http://www.microsoft.com/download/en/details.aspx?id=8729

This is included in the Windows Phone Tools for the next version ("Mango / 7.5") as well.  Microsoft.Advertising.Mobile.Xna

Jul 31, 2011 at 1:30 AM

Thanks for the reply clint. I am aware of the ad control, and I have tried implementing it, but having difficultites getting it to load somewhere in the GameScreen Class.

I've created an instance of the AdManager, but I don't know where to place the code below. I've tried GameScreen.LoadGraphics but to no avail.

myad = AdManager.CreateAd("Image300_50", new Rectangle(0, 20, Manager.GraphicsDevice.Viewport.Bounds.Width, 120), RotationMode.Manual, false);

Am I missing something?

Thanks in advance.

Developer
Aug 1, 2011 at 12:32 AM

As I understand it, the AD SDK works using the component system built into the XNA Game class. You can find a sample here:

http://code.msdn.microsoft.com/Advertising-SDK-for-91c0d463/sourcecode?fileId=23967&pathId=2035935777

This means you need to initialise the AdManager and add it to the component list. You shouldn't need to worry about drawing it. You should do this inside SampleGame.cs in Coding4Fun.ScriptTD.Sample.

In the example I linked to, all of the ad creation is done inside the Initialize method, but I think the main thing to ensure is that you are calling Components.Add(AdGameComponent.Current) after initialising the AdGameComponent.