// 间隔时间及其它初始化

XNA:

TargetElapsedTime = TimeSpan.FromTicks(333333); 

 Silverlight:    contentManager = (Application.Current as App).Content;             timer = new GameTimer();
            timer.UpdateInterval = TimeSpan.FromTicks(333333);
            timer.Update += OnUpdate;
            timer.Draw += OnDraw;

加载页面:

XNA:     

 protected override void LoadContent()
        {
                           spriteBatch = new SpriteBatch(GraphicsDevice);
            texture1 = Content.Load<Texture2D>("PhoneGameThumb");
                     soundEffect = Content.Load<SoundEffect>("Windows Ding");

                     spritePosition2.X = graphics.GraphicsDevice.Viewport.Width - texture1.Width;
            spritePosition2.Y = graphics.GraphicsDevice.Viewport.Height - texture1.Height;

}

sliverlight:

 protected override void OnNavigatedTo(NavigationEventArgs e)
        {
              SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);

              spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);

                        texture1 = contentManager.Load<Texture2D>("PhoneGameThumb");
                   texture2 = contentManager.Load<Texture2D>("PhoneGameThumb");
                         soundEffect = contentManager.Load<SoundEffect>("Windows Ding");

                                           spritePosition2.X = (float)ActualWidth - texture1.Width;
            spritePosition2.Y = (float)ActualHeight - texture1.Height;
                        sprite1Height = texture1.Bounds.Height;
            sprite1Width = texture1.Bounds.Width;

                       timer.Start();

            base.OnNavigatedTo(e);
        }

更新页面:

XNA:   

 protected override void Update(GameTime gameTime)
        {
                    UpdateSprite(gameTime, ref spritePosition1, ref spriteSpeed1);
            UpdateSprite(gameTime, ref spritePosition2, ref spriteSpeed2);
                  base.Update(gameTime);
        }

silverlight:

   private void OnUpdate(object sender, GameTimerEventArgs e)
        {                           

            UpdateSprite( ref spritePosition1, ref spriteSpeed1);
            UpdateSprite(ref spritePosition2, ref spriteSpeed2);
                    }

绘制:

XNA:

  protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

                     spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
            spriteBatch.Draw(texture1, spritePosition1, Color.White);
            spriteBatch.End();         
            base.Draw(gameTime);
        }

silverlight:

 private void OnDraw(object sender, GameTimerEventArgs e)
        {
            SharedGraphicsDeviceManager.Current.GraphicsDevice.Clear(Color.CornflowerBlue);

                     spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
            spriteBatch.Draw(texture1, spritePosition1, Color.White);
            spriteBatch.End();

}