XNA AdGameComponent不绘制

时间:2011-11-25 17:34:49

标签: c# windows-phone-7 xna components ads

我有以下代码。 但是AddGameComponent没有绘制。

   protected override void Initialize()
    {
        // TODO: Add your initialization logic here
        base.Initialize();
        var li = new LicenseInformation();
        IsTrial = li.IsTrial();
        if (IsTrial)
        {
            AdGameComponent.Initialize(this, AppID);
            Components.Add(AdGameComponent.Current);
            CreateAd();
        }
    }


   private void CreateAd()
    {
        bannerAd = AdGameComponent.Current.CreateAd(AdUnitID, new Rectangle(x, y, width, height), true);
        AdGameComponent.Current.Enabled = true;
    }

我尝试将DrawOrder设置为1000,但广告仍无效。

2 个答案:

答案 0 :(得分:2)

您应该从AdGameComponent调用相应的Draw和Update方法,请参阅文档:http://msdn.microsoft.com/en-us/library/hh495436(v=MSADS.20).aspx

答案 1 :(得分:0)

答案:广告需要地理位置数据。

this.gcw = new GeoCoordinateWatcher(); 
this.gcw.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(gcw_PositionChanged); 
this.gcw.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(gcw_StatusChanged); 
this.gcw.Start();