C# Class MonoGameFoundation.Animation

Animates a series of frames on a specified row of a sprite sheet.
Show file Open project: half-ogre/MonoGameQuest Class Usage Examples

Public Methods

Method Description
Animation ( Microsoft.Xna.Framework.Graphics.Texture2D spriteSheet, int spriteSheetRow, int framePixelWidth, int framePixelHeight, int framesLength, int frameDuration, bool flipHorizontally = false ) : System

Creates a new Animation instance.

Draw ( SpriteBatch spriteBatch, Vector2 position, float scale ) : void

Draw the current frame.

Reset ( ) : void

Resets the animation to the initial frame.

Update ( GameTime gameTime ) : void

Updates the current frame of the animation.

Method Details

Animation() public method

Creates a new Animation instance.
public Animation ( Microsoft.Xna.Framework.Graphics.Texture2D spriteSheet, int spriteSheetRow, int framePixelWidth, int framePixelHeight, int framesLength, int frameDuration, bool flipHorizontally = false ) : System
spriteSheet Microsoft.Xna.Framework.Graphics.Texture2D The source sprite sheet containing the row of frames to animate.
spriteSheetRow int The row in the sprite sheet containing the frames to animate.
framePixelWidth int The width in pixels of each frame in the row.
framePixelHeight int The height in pixel of each frame in the row.
framesLength int The number of frames in the row.
frameDuration int The time, in milliseconds, to display each frame.
flipHorizontally bool A flag specifying whether to flip the animation horizontally (e.g., to turn an animation facing the right into a left-facing animation).
return System

Draw() public method

Draw the current frame.
public Draw ( SpriteBatch spriteBatch, Vector2 position, float scale ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch The SpriteBatch in which to draw.
position Vector2 The position at which to draw.
scale float The scale at which to draw.
return void

Reset() public method

Resets the animation to the initial frame.
public Reset ( ) : void
return void

Update() public method

Updates the current frame of the animation.
public Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void