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.
Afficher le fichier Open project: Bacon41/PantheonPrototype

Protected Properties

Свойство Type Description
rotation float

Méthodes publiques

Méthode 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 méthode

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
Résultat void

Sprite() public méthode

public Sprite ( ) : System
Résultat System

Sprite() public méthode

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

Sprite() public méthode

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
Résultat System

Update() public méthode

public Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
Résultat void

addState() public méthode

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.
Résultat void

changeState() public méthode

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

getState() public méthode

This method returns the name of the curren state.
public getState ( ) : string
Résultat string

isComplete() public méthode

public isComplete ( ) : bool
Résultat bool

loadSprite() public méthode

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
Résultat void

loadSprite() public méthode

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.
Résultat void

removeState() public méthode

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

Property Details

rotation protected_oe property

protected float rotation
Résultat float