public void Draw(SpriteBatch spriteBatch) { Rectangle sourceRectangle; Rectangle destinationRectangle; if (currentFrame < 3) { sourceRectangle = new Rectangle(0, 0, 96, 162); destinationRectangle = new Rectangle((int)GlobalDefinitions.Position.X, (int)GlobalDefinitions.Position.Y, 96, 162);//I don't understand why the width of destinationRectangle has to be like this. } else if (3 <= currentFrame && currentFrame < 6) { sourceRectangle = new Rectangle(96, 0, 96, 162); destinationRectangle = new Rectangle((int)GlobalDefinitions.Position.X, (int)GlobalDefinitions.Position.Y, 96, 162); } else if (6 <= currentFrame && currentFrame < 9) { sourceRectangle = new Rectangle(192, 0, 96, 162); destinationRectangle = new Rectangle((int)GlobalDefinitions.Position.X, (int)GlobalDefinitions.Position.Y, 96, 162); } else { sourceRectangle = new Rectangle(288, 0, 96, 162); destinationRectangle = new Rectangle((int)GlobalDefinitions.Position.X, (int)GlobalDefinitions.Position.Y, 96, 162); } spriteBatch.Draw(Texture2DStorage.GetDownWoodenSwordLinkSpriteSheet(), destinationRectangle, sourceRectangle, Color.White);//use Texture2DStorage class to load texture2D }
public void Draw(SpriteBatch spriteBatch, Vector2 Position) { Rectangle sourceRectangle; if (currentFrame < 3) { sourceRectangle = new Rectangle(0, 0, 96, 162); destinationRectangle = new Rectangle((int)GlobalDefinitions.Position.X, (int)GlobalDefinitions.Position.Y, 96, 162); } else if (3 <= currentFrame && currentFrame < 6) { sourceRectangle = new Rectangle(96, 0, 96, 162); destinationRectangle = new Rectangle((int)GlobalDefinitions.Position.X, (int)GlobalDefinitions.Position.Y, 96, 162); } else if (6 <= currentFrame && currentFrame < 9) { sourceRectangle = new Rectangle(192, 0, 96, 162); destinationRectangle = new Rectangle((int)GlobalDefinitions.Position.X, (int)GlobalDefinitions.Position.Y, 96, 162); } else { sourceRectangle = new Rectangle(288, 0, 96, 162); destinationRectangle = new Rectangle((int)GlobalDefinitions.Position.X, (int)GlobalDefinitions.Position.Y, 96, 162); } spriteBatch.Draw(Texture2DStorage.GetDownWoodenSwordLinkSpriteSheet(), destinationRectangle, sourceRectangle, Color.White);//use Texture2DStorage class to load texture2D if (currentFrame == totalFrame) { Link.State.Stop(); } }
public void Draw(SpriteBatch spriteBatch) { GetSprite.Draw(Texture2DStorage.GetDownWoodenSwordLinkSpriteSheet(), spriteBatch, GlobalDefinitions.Position); }