简体   繁体   English

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

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

I'm tring to use the advertising control in my XNA WP7 application. 我打算在XNA WP7应用程序中使用广告控件。 It displays well but I'm unable to click on it, try with this code : 它显示得很好,但我无法单击它,请尝试使用以下代码:

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);
    }
}

What's wrong with this code ? 此代码有什么问题?

Thanks in advance for any help. 在此先感谢您的帮助。

Best regards 最好的祝福

NB : the sample is working if the component starts in visible state, but it's not what I want because I would like to put it not at the start of my application 注意:如果组件以可见状态启动,则示例正在运行,但这不是我想要的,因为我不想在应用程序的开头放置它

There's a bug in the SDK If I take the latest version, it's ok SDK中存在错误如果我使用最新版本,就可以了

see http://community.microsoftadvertising.com/en/developer/pubcenter/f/32/t/72786.aspx 请参阅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