http://geekswithblogs.net/cwilliams/archive/2011/03/20/144452.aspx
我尝试了本教程,但总是收到以下三条错误消息:
找不到类型或命名空间名称“Ad”(您是否缺少using指令或程序集引用?)
找不到类型或命名空间名称“AdManager”(您是否缺少using指令或程序集引用?)
当前上下文中不存在名称“RotationMode”
有什么问题?我已经添加了“使用Microsoft.Advertising.Mobile.Xna;”,但我总是收到这些错误消息。
如何在XNA Windows Phone游戏中使用pubcenter广告?
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
private const string AppID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
private const string AdUnitID = "xxxxx";
AdManager adManager;
Ad bannerAd;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
TargetElapsedTime = TimeSpan.FromTicks(333333);
InactiveSleepTime = TimeSpan.FromSeconds(1);
graphics.IsFullScreen = true;
}
protected override void Initialize()
{
adManager = new AdManager(this, AppID);
adManager.TestMode = false;
Components.Add(adManager);
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
bannerAd = adManager.CreateAd(AdUnitID, new Rectangle(0, 20, GraphicsDevice.Viewport.Bounds.Width, 120), RotationMode.Manual, false);
}
protected override void Update(GameTime gameTime)
{
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
}
}