Полный код
usingMicrosoft.Xna.Framework;usingMicrosoft.Xna.Framework.Graphics;usingMicrosoft.Xna.Framework.Input;namespaceGame1{publicclassGame1 : Game{GraphicsDeviceManager graphics;SpriteBatch spriteBatch;Texture2D texture;Vector2 position = Vector2.Zero;intframeWidth = 108;intframeHeight = 140;Point currentFrame =newPoint(0, 0);Point spriteSize =newPoint(8, 2);publicGame1(){graphics =newGraphicsDeviceManager(this);Content.RootDirectory ="Content";TargetElapsedTime =newSystem.TimeSpan(0, 0, 0, 0, 400);}protectedoverridevoidInitialize(){base.Initialize();}protectedoverridevoidLoadContent(){spriteBatch =newSpriteBatch(GraphicsDevice);texture = Content.Load<Texture2D>("scottpilgrim_multiple");}protectedoverridevoidUnloadContent(){}protectedoverridevoidUpdate(GameTime gameTime){if(GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))Exit();++currentFrame.X;if(currentFrame.X >= spriteSize.X){currentFrame.X = 0;++currentFrame.Y;if(currentFrame.Y >= spriteSize.Y)currentFrame.Y = 0;}base.Update(gameTime);}protectedoverridevoidDraw(GameTime gameTime){GraphicsDevice.Clear(Color.CornflowerBlue);spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);spriteBatch.Draw(texture, position,newRectangle(currentFrame.X * frameWidth,currentFrame.Y * frameHeight,frameWidth, frameHeight),Color.White, 0, Vector2.Zero,1, SpriteEffects.None, 0);spriteBatch.End();base.Draw(gameTime);}}}
Source: Blog
411