繁体   English   中英

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

[英]Advertising for XNA WP7 application, unable to click

我打算在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);
    }
}

此代码有什么问题?

在此先感谢您的帮助。

最好的祝福

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

SDK中存在错误如果我使用最新版本,就可以了

请参阅http://community.microsoftadvertising.com/zh-CN/developer/pubcenter/f/32/t/72786.aspx

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM