C# Class PantheonPrototype.Sprite

Provides a basic class for managing a sprite on screen. This class contains a loading method, a potential state system, and a drawing method.
Exibir arquivo Open project: Bacon41/PantheonPrototype

Protected Properties

Property Type Description
rotation float

Public Methods

Method Description
Draw ( SpriteBatch canvas, Rectangle location, Vector2 origin ) : void

Draws the sprite to the screen at the given location.

Sprite ( ) : System
Sprite ( Microsoft.Xna.Framework.Graphics.Texture2D image, int rows, int columns ) : System
Sprite ( Microsoft.Xna.Framework.Graphics.Texture2D image, int rows, int columns, bool backAndForth ) : System
Update ( GameTime gameTime ) : void
addState ( string state, int first, int last, bool looping, bool sweeping ) : void

Creates a new state and adds it to the sprite. Deletes the default state the first time this is called. If the current state is the default state, the method shall check to see if the current frame is outside of the new range and shall adjust so that it is not.

changeState ( string state ) : bool

Changes the current animation state of the sprite.

getState ( ) : string

This method returns the name of the curren state.

isComplete ( ) : bool
loadSprite ( Microsoft.Xna.Framework.Graphics.Texture2D image, int rows, int columns, bool sweeping ) : void

Loads a sprite with an image. Note: This function will clear any classes

loadSprite ( Microsoft.Xna.Framework.Graphics.Texture2D image, int rows, int columns, int frameRate ) : void

Alternative wrapper for backwards compatibility

removeState ( string state ) : void

Removes the specified state from the sprite.

Method Details

Draw() public method

Draws the sprite to the screen at the given location.
public Draw ( SpriteBatch canvas, Rectangle location, Vector2 origin ) : void
canvas Microsoft.Xna.Framework.Graphics.SpriteBatch An initialized SpriteBatch to which the sprite will be drawn.
location Microsoft.Xna.Framework.Rectangle The location as a vector to which the sprite should be drawn.
origin Vector2 The origin around which the sprite should rotate
return void

Sprite() public method

public Sprite ( ) : System
return System

Sprite() public method

public Sprite ( Microsoft.Xna.Framework.Graphics.Texture2D image, int rows, int columns ) : System
image Microsoft.Xna.Framework.Graphics.Texture2D
rows int
columns int
return System

Sprite() public method

public Sprite ( Microsoft.Xna.Framework.Graphics.Texture2D image, int rows, int columns, bool backAndForth ) : System
image Microsoft.Xna.Framework.Graphics.Texture2D
rows int
columns int
backAndForth bool
return System

Update() public method

public Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void

addState() public method

Creates a new state and adds it to the sprite. Deletes the default state the first time this is called. If the current state is the default state, the method shall check to see if the current frame is outside of the new range and shall adjust so that it is not.
public addState ( string state, int first, int last, bool looping, bool sweeping ) : void
state string The name for the new state.
first int The first frame of the new state.
last int The last frame of the new state.
looping bool Whether or not the animation of the current state should loop.
sweeping bool Whether or not the animation of the current state plays back and forth.
return void

changeState() public method

Changes the current animation state of the sprite.
public changeState ( string state ) : bool
state string The new state for the sprite.
return bool

getState() public method

This method returns the name of the curren state.
public getState ( ) : string
return string

isComplete() public method

public isComplete ( ) : bool
return bool

loadSprite() public method

Loads a sprite with an image. Note: This function will clear any classes
public loadSprite ( Microsoft.Xna.Framework.Graphics.Texture2D image, int rows, int columns, bool sweeping ) : void
image Microsoft.Xna.Framework.Graphics.Texture2D The image to be used for the sprite.
rows int The number of frame rows in the image.
columns int The number of frame columns in the image.
sweeping bool
return void

loadSprite() public method

Alternative wrapper for backwards compatibility
public loadSprite ( Microsoft.Xna.Framework.Graphics.Texture2D image, int rows, int columns, int frameRate ) : void
image Microsoft.Xna.Framework.Graphics.Texture2D The image to be used for the sprite.
rows int The number of frame rows in the image.
columns int The number of frame columns in the image.
frameRate int The frame rate at which the sprite updates.
return void

removeState() public method

Removes the specified state from the sprite.
public removeState ( string state ) : void
state string The name of the state to remove.
return void

Property Details

rotation protected_oe property

protected float rotation
return float