XNA WP7 应用程序的广告,无法点击

本文关键字:WP7 应用程序 XNA | 更新日期: 2023-09-27 18:33:47

我想在我的XNA WP7应用程序中使用广告控件。它显示得很好,但我无法单击它,请尝试使用此代码:

public class Game1 : Microsoft.Xna.Framework.Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    private DrawableAd bannerAd;
    private bool shouldDraw;
    private const string guid = "xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; // my id is hidden
    private const string idapp = "00000";
    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
        TargetElapsedTime = TimeSpan.FromTicks(333333);
        InactiveSleepTime = TimeSpan.FromSeconds(1);
    }
    protected override void Initialize()
    {
        AdGameComponent.Initialize(this, guid);
        CreateAd();
        Components.Add(AdGameComponent.Current);
        AdGameComponent.Current.Enabled = true;
        AdGameComponent.Current.Visible = false;
        base.Initialize();
    }
    private void CreateAd()
    {
        // Create a banner ad for the game.
        int width = 480;
        int height = 80;
        int x = (GraphicsDevice.Viewport.Bounds.Width - width) / 2; // centered on the display
        int y = 390;
        bannerAd = AdGameComponent.Current.CreateAd(idapp, new Rectangle(x, y, width, height), true);
    }
    protected override void LoadContent()
    {
        spriteBatch = new SpriteBatch(GraphicsDevice);
    }
    protected override void UnloadContent()
    {
    }
    protected override void Update(GameTime gameTime)
    {
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            this.Exit();
        TouchCollection touchPoints = TouchPanel.GetState();
        if (touchPoints.Count > 0)
        {
            TouchLocation t = touchPoints[0];
            if (t.State == TouchLocationState.Pressed)
            {
                shouldDraw = true;
            }
        }

        base.Update(gameTime);
    }
    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);
        if (shouldDraw)
        {
            shouldDraw = false;
            AdGameComponent.Current.Visible = true;
        }
        base.Draw(gameTime);
    }
}

这段代码有什么问题?

提前感谢任何帮助。

此致敬意

注意:如果组件以可见状态启动,则示例可以工作,但这不是我想要的,因为我想不把它放在应用程序的开头

XNA WP7 应用程序的广告,无法点击

SDK 中存在错误如果我使用最新版本,没关系

见 http://community.microsoftadvertising.com/en/developer/pubcenter/f/32/t/72786.aspx