AgateLib.Sprites.Old.SpriteContainer< T > Class Template 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.
void Clear ()
 Clears all sprites from this collection. Sprites are not disposed of. If you want them disposed, call DisposeAllSprites() first.
IEnumerator< KeyValuePair< T,
Sprite > > 
GetEnumerator ()
 Enumerates through KeyValuePair<T, Sprite> objects in this collection.
void DisposeAllSprites ()
 Disposes of all sprites in the collection.

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.
int Count [get]
 Returns how many items are contained.
bool IsReadOnly [get]
 This is always false.


Detailed Description

template<T>
class AgateLib::Sprites::Old::SpriteContainer< T >

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.

Template Parameters:
T 

Member Function Documentation

template<T >
void AgateLib.Sprites.Old.SpriteContainer< T >.Add ( key,
Sprite  value 
)

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

Parameters:
key 
value 

template<T >
void AgateLib.Sprites.Old.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.

template<T >
void AgateLib.Sprites.Old.SpriteContainer< T >.Clear (  ) 

Clears all sprites from this collection. Sprites are not disposed of. If you want them disposed, call DisposeAllSprites() first.

template<T >
bool AgateLib.Sprites.Old.SpriteContainer< T >.ContainsKey ( key  ) 

Checks to see if the collection contains the specified key.

Parameters:
key 
Returns:

template<T >
void AgateLib.Sprites.Old.SpriteContainer< T >.DisposeAllSprites (  ) 

Disposes of all sprites in the collection.

template<T >
void AgateLib.Sprites.Old.SpriteContainer< T >.Draw ( PointF  dest  ) 

Draws the current sprite at the specified destination point.

Parameters:
dest 

template<T >
void AgateLib.Sprites.Old.SpriteContainer< T >.Draw ( float  dest_x,
float  dest_y 
)

Draws the current sprite at the specified destination point.

Parameters:
dest_x 
dest_y 

template<T >
void AgateLib.Sprites.Old.SpriteContainer< T >.Draw ( Point  dest  ) 

Draws the current sprite at the specified destination point.

Parameters:
dest 

template<T >
void AgateLib.Sprites.Old.SpriteContainer< T >.Draw ( int  destX,
int  destY 
)

Draws the current sprite at the specified destination.

Parameters:
destX 
destY 

template<T >
IEnumerator<KeyValuePair<T, Sprite> > AgateLib.Sprites.Old.SpriteContainer< T >.GetEnumerator (  ) 

Enumerates through KeyValuePair<T, Sprite> objects in this collection.

Returns:

template<T >
bool AgateLib.Sprites.Old.SpriteContainer< T >.Remove ( key  ) 

Removes a Sprite from this collection.

Parameters:
key 
Returns:

template<T >
bool AgateLib.Sprites.Old.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:

template<T >
bool AgateLib.Sprites.Old.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:

template<T >
void AgateLib.Sprites.Old.SpriteContainer< T >.SetScale ( double  x,
double  y 
)

Sets the scale factor for all sprites in this collection.

Parameters:
x 
y 

template<T >
bool AgateLib.Sprites.Old.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:

template<T >
void AgateLib.Sprites.Old.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.

template<T >
void AgateLib.Sprites.Old.SpriteContainer< T >.Update (  ) 

Calls Update on each of the sprites in the collection.


Property Documentation

template<T >
int AgateLib.Sprites.Old.SpriteContainer< T >.Count [get]

Returns how many items are contained.

template<T >
Sprite AgateLib.Sprites.Old.SpriteContainer< T >.CurrentSprite [get]

Gets the current sprite object.

template<T >
T AgateLib.Sprites.Old.SpriteContainer< T >.CurrentSpriteKey [get]

Returns the key value for the current sprite.

template<T >
OriginAlignment AgateLib.Sprites.Old.SpriteContainer< T >.DisplayAlignment [set]

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

template<T >
bool AgateLib.Sprites.Old.SpriteContainer< T >.IsReadOnly [get]

This is always false.

template<T >
ICollection<T> AgateLib.Sprites.Old.SpriteContainer< T >.Keys [get]

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

template<T >
Sprite AgateLib.Sprites.Old.SpriteContainer< T >.this[T key] [get]

Gets the sprite object corresponding to the given key.

Parameters:
key 
Returns:

template<T >
ICollection<Sprite> AgateLib.Sprites.Old.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