ERY.AgateLib.SpriteContainer< T > Class Reference

A generic class which is used to contain multiple animation sequences (sprites). You provide your own key for identifying sprites. Typically, T should be some enum type which specifies all of the animations used by a particular object. More...

List of all members.

Public Member Functions

void AddSprite (T key, string filename, int width, int height)
 Adds an animation sequence to the list. This automatically creates a new Sprite object, passing the filename and width and height of a frame to it.
bool SetCurrentSprite (T key, bool beginAnimation)
 Sets the currently displayed sprite for this collection. Returns true if the key was present, false if the key was not found.
bool SetCurrentSprite (T[] keys, bool beginAnimation)
 Sets the currently displayed sprite for this collection. Returns true if either the key or the default key was set.
void Update ()
 Calls Update on each of the sprites in the collection.
void Update (double time_ms)
 Updates the animation of all contained sprites, using the given frame time.
void Draw (int destX, int destY)
 Draws the current sprite at the specified destination.
void Draw (Point dest)
 Draws the current sprite at the specified destination point.
void Draw (float dest_x, float dest_y)
 Draws the current sprite at the specified destination point.
void Draw (PointF dest)
 Draws the current sprite at the specified destination point.
void SetScale (double x, double y)
 Sets the scale factor for all sprites in this collection.
void Add (T key, Sprite value)
 Adds a sprite to the collection, for the specified key.
bool ContainsKey (T key)
 Checks to see if the collection contains the specified key.
bool Remove (T key)
 Removes a Sprite from this collection.
bool TryGetValue (T key, out Sprite value)
 Tries to get the value of the Sprite at the specified key, returning true if successful.

Properties

Sprite this [T key] [get]
 Gets the sprite object corresponding to the given key.
Sprite CurrentSprite [get]
 Gets the current sprite object.
CurrentSpriteKey [get]
 Returns the key value for the current sprite.
OriginAlignment DisplayAlignment [set]
 Sets the display alignment property for all sprites in this collection.
ICollection< T > Keys [get]
 Returns a collection of all the keys contained in this SpriteContainer.
ICollection< SpriteValues [get]
 Returns a collection of all the Sprites in this collection.


Detailed Description

A generic class which is used to contain multiple animation sequences (sprites). You provide your own key for identifying sprites. Typically, T should be some enum type which specifies all of the animations used by a particular object.

A SpriteContainer<T> implements the IDictionary<T, Sprite> interface, so it can be thought of as a dictionary of animations. It also contains state information like what the current sprite is.

<typeparam name="T"></typeparam>


Member Function Documentation

void ERY.AgateLib.SpriteContainer< T >.AddSprite ( key,
string  filename,
int  width,
int  height 
)

Adds an animation sequence to the list. This automatically creates a new Sprite object, passing the filename and width and height of a frame to it.

Parameters:
key The key value for this animation sequence.
filename Filename to load animation files from
width Width in pixels of a single frame.
height Height in pixels of a single frame.

bool ERY.AgateLib.SpriteContainer< T >.SetCurrentSprite ( key,
bool  beginAnimation 
)

Sets the currently displayed sprite for this collection. Returns true if the key was present, false if the key was not found.

Parameters:
key The key to set for the current sprite.
beginAnimation True to restart the animation.
Returns:

bool ERY.AgateLib.SpriteContainer< T >.SetCurrentSprite ( T[]  keys,
bool  beginAnimation 
)

Sets the currently displayed sprite for this collection. Returns true if either the key or the default key was set.

Parameters:
keys An array of keys to try setting to.
beginAnimation True to restart the animation.
Returns:

void ERY.AgateLib.SpriteContainer< T >.Update (  ) 

Calls Update on each of the sprites in the collection.

void ERY.AgateLib.SpriteContainer< T >.Update ( double  time_ms  ) 

Updates the animation of all contained sprites, using the given frame time.

Parameters:
time_ms The amount of time to consider passed, in milliseconds.

void ERY.AgateLib.SpriteContainer< T >.Draw ( int  destX,
int  destY 
)

Draws the current sprite at the specified destination.

Parameters:
destX 
destY 

void ERY.AgateLib.SpriteContainer< T >.Draw ( Point  dest  ) 

Draws the current sprite at the specified destination point.

Parameters:
dest 

void ERY.AgateLib.SpriteContainer< T >.Draw ( float  dest_x,
float  dest_y 
)

Draws the current sprite at the specified destination point.

Parameters:
dest_x 
dest_y 

void ERY.AgateLib.SpriteContainer< T >.Draw ( PointF  dest  ) 

Draws the current sprite at the specified destination point.

Parameters:
dest 

void ERY.AgateLib.SpriteContainer< T >.SetScale ( double  x,
double  y 
)

Sets the scale factor for all sprites in this collection.

Parameters:
x 
y 

void ERY.AgateLib.SpriteContainer< T >.Add ( key,
Sprite  value 
)

Adds a sprite to the collection, for the specified key.

Parameters:
key 
value 

bool ERY.AgateLib.SpriteContainer< T >.ContainsKey ( key  ) 

Checks to see if the collection contains the specified key.

Parameters:
key 
Returns:

bool ERY.AgateLib.SpriteContainer< T >.Remove ( key  ) 

Removes a Sprite from this collection.

Parameters:
key 
Returns:

bool ERY.AgateLib.SpriteContainer< T >.TryGetValue ( key,
out Sprite  value 
)

Tries to get the value of the Sprite at the specified key, returning true if successful.

Parameters:
key 
value 
Returns:


Property Documentation

Sprite ERY.AgateLib.SpriteContainer< T >.this[T key] (  )  [get]

Gets the sprite object corresponding to the given key.

Parameters:
key 
Returns:

Sprite ERY.AgateLib.SpriteContainer< T >.CurrentSprite [get]

Gets the current sprite object.

T ERY.AgateLib.SpriteContainer< T >.CurrentSpriteKey [get]

Returns the key value for the current sprite.

OriginAlignment ERY.AgateLib.SpriteContainer< T >.DisplayAlignment [set]

Sets the display alignment property for all sprites in this collection.

ICollection<T> ERY.AgateLib.SpriteContainer< T >.Keys [get]

Returns a collection of all the keys contained in this SpriteContainer.

ICollection<Sprite> ERY.AgateLib.SpriteContainer< T >.Values [get]

Returns a collection of all the Sprites in this collection.


The documentation for this class was generated from the following file:
AgateLib
Awesome Game and Tool Engine Library
SourceForge.net Logo