ERY.AgateLib.Sprite Class Reference

The Sprite class represents a series of frames which are used to create a single animation. More...

List of all members.

Public Types

enum  AnimType {
  Looping, PingPong, Once, OnceHoldLast,
  OnceDisappear, Twice
}
 Enum indicating the different types of automatic animation that take place. More...

Public Member Functions

 Sprite (int width, int height)
 Constructs a Sprite object, of the specified width and height.
 Sprite (Size size)
 Constructs a Sprite object, of the specified width and height.
 Sprite (string filename, Size size)
 Constructs a Sprite object, of the specified width and height. The given file is loaded automatically, and frames are cut out from it of the specified size.
 Sprite (string filename, int width, int height)
 Constructs a Sprite object, of the specified width and height. The given file is loaded automatically, and frames are cut out from it of the specified size.
 Sprite (Surface surface, Size size)
 Constructs a Sprite object, of the specified width and height. Frames are cut out from the given surface of the specified size.
 Sprite (Surface surface, int width, int height)
 Constructs a Sprite object, of the specified width and height. Frames are cut out from the given surface of the specified size.
 Sprite (string name, ResourceManager resources)
 Constructs a Sprite object, loading it from the file specified in the given ResourceManager object.
Sprite Clone ()
 Makes a copy of this sprite and returns it.
void Dispose ()
 Disposes of unmanaged resources associated with this sprite.
void AddFrames (string filename)
 Slices and dices the image passed into frames and adds them. Automatically skips blank ones.
void AddFrames (Surface surface)
 Adds frames from the given surface, using the size of this sprite.
void AddFrames (string filename, Point startPoint, Point extraSpace, bool skipBlank)
 Adds frames from the given filename, using the size of this sprite. Frames are taken from startPoint, and with extraSpace inbetween.
void AddFrames (Surface surface, Point startPoint, Point extraSpace, bool skipBlank)
 Adds frames from the given surface, using the size of this sprite. Frames are taken from startPoint, and with extraSpace inbetween.
void AddFrames (Surface surface, Point startPoint, Point extraSpace, Size size, bool skipBlank)
 Slices and dices the image passed into frames and adds them. Frames are taken from the surface from left to right.
void AddFrames (Surface surface, Point startPoint, Point extraSpace, Size size, Size array)
 Slices and dices the image passed into frames and adds them. Frames are taken from the surface from left to right.
void Draw (Rectangle destRect)
 Draw the sprite to the given destination rectangle. Overrides scaling settings.
void Draw (int destX, int destY)
 Draws the sprite at the specified position on screen.
void Draw (float destX, float destY)
 Draws the sprite at the specified position on screen.
void Draw (Point destPt)
 Draws the sprite at the specified position on screen.
void Draw (PointF destPt)
 Draws the sprite at the specified position on screen.
void DrawPoints (Point[] dest_pts)
 Draws the sprite at all the specified positions on screen.
void Draw ()
 Draws the sprite at the origin.
void DrawRects (Rectangle[] dest_rects)
 Draws the sprite at the specified rectangles.
void SetScale (double x, double y)
 Sets the scale of the sprite.
void GetScale (out double x, out double y)
 Gets the scale of the sprite.
void IncrementRotationAngle (double radians)
 Increments the rotation angle by the specified number of radians.
void IncrementRotationAngleDegrees (double degrees)
 Increments the rotation angle by the specified number of degrees.
void Update ()
 Updates the animation of the sprite, using the DeltaTime given by the Display object.
void Update (double time_ms)
 Updates the animation of the sprite, using the given frame time.
void AdvanceFrame ()
 Shows the next frame in the sequence. This pays attention to whether the animation is playing forwards or reverse.
void StartAnimation ()
 Restarts the animation.
delegate void SpriteEventHandler (Sprite sprite)
 Event handler type for sprite events.

Public Attributes

event SpriteEventHandler AnimationStopped
 Event which is raised when the animation is stopped.
event SpriteEventHandler AnimationStarted
 Event which is raised when the animation is started.
event SpriteEventHandler PlayDirectionChanged
 Event which is raised when the play direction is changed, as in the PingPong type.

Properties

static bool UseSpriteCache [get, set]
 Bool which indicates whether sprite frames should be cached to disk after they've been cut out. Speed up loading if used.
static string SpriteCachePath [get, set]
 Sets the path where SpriteFrames are saved, if the sprite cache is used.
int SpriteWidth [get]
 Gets width of the sprite.
int SpriteHeight [get]
 Gets height of the sprite.
Size SpriteSize [get]
 Gets the size of the sprite.
int DisplayWidth [get, set]
 Gets the width of the sprite when displayed.
int DisplayHeight [get, set]
 Gets the height of the sprite when displayed.
Size DisplaySize [get, set]
 Gets or sets the size of the sprite when displayed.
double Alpha [get, set]
 Gets or sets transparency value. 0.0 is completely transparent 1.0 is completely opaque.
double RotationAngle [get, set]
 Gets or sets the rotation angle in radians.
double RotationAngleDegrees [get, set]
 Gets or sets the rotation angle in degrees.
OriginAlignment RotationCenter [get, set]
 Gets or sets the center of rotation.
OriginAlignment DisplayAlignment [get, set]
 Gets or sets the interpretation of the position.
Color Color [get, set]
 Gets or sets the color of the sprite.
bool Visible [get, set]
 Gets or sets whether or not the sprite should be drawn when Draw is called.
double TimePerFrame [get, set]
 The amount of time each frame should display, in milliseconds.
int CurrentFrameIndex [get, set]
 The index of the current frame.
SpriteFrame CurrentFrame [get]
 Gets the currently displaying frame.
bool PlayReverse [get, set]
 Gets or sets a flag which indicates whether or not this animation plays in reverse instead.
AnimType AnimationType [get, set]
 Gets or sets an enum value indicating what type of animation is happening. Looping - The animation will play from beginning to end and then restart. PingPong - The animation will play from beginning to end and then from end to beginning (continuously). Once - The animation plays once, and then shows its first frame. OnceHoldLast - The animation plays once, and leaves the last frame on.
bool Animating [get, set]
 Gets or sets a flag which indicates: True if the animation is running. False if a single frame will be shown indefinitely.
List< SpriteFrameFrames [get]
 Gets the list of SpriteFrame objects in this sprite.


Detailed Description

The Sprite class represents a series of frames which are used to create a single animation.


Member Enumeration Documentation

enum ERY::AgateLib::Sprite::AnimType

Enum indicating the different types of automatic animation that take place.

Enumerator:
Looping  Specifies that the sprite animation should go from frame 0 to the end, and start back at frame 0.

PingPong  Specifies that the sprite animation should go from frame 0 to the end, and then go back down to frame 0.

Once  Specifies that the sprite animation should go from frame 0 to the end and then back to frame 0, stopping there.

OnceHoldLast  Specifies that the sprite animation should go from frame 0 to the end and stop there.

OnceDisappear  Specifies that the sprite animation should go from frame 0 to the end, and then disappear. The Visible property of the Sprite object is set to false once the animation is complete.

Twice  Specifies that the sprite animation should go twice.


Constructor & Destructor Documentation

ERY.AgateLib.Sprite.Sprite ( int  width,
int  height 
)

Constructs a Sprite object, of the specified width and height.

Parameters:
width 
height 

ERY.AgateLib.Sprite.Sprite ( Size  size  ) 

Constructs a Sprite object, of the specified width and height.

Parameters:
size 

ERY.AgateLib.Sprite.Sprite ( string  filename,
Size  size 
)

Constructs a Sprite object, of the specified width and height. The given file is loaded automatically, and frames are cut out from it of the specified size.

Parameters:
filename 
size 

ERY.AgateLib.Sprite.Sprite ( string  filename,
int  width,
int  height 
)

Constructs a Sprite object, of the specified width and height. The given file is loaded automatically, and frames are cut out from it of the specified size.

Parameters:
filename 
width 
height 

ERY.AgateLib.Sprite.Sprite ( Surface  surface,
Size  size 
)

Constructs a Sprite object, of the specified width and height. Frames are cut out from the given surface of the specified size.

Parameters:
surface 
size 

ERY.AgateLib.Sprite.Sprite ( Surface  surface,
int  width,
int  height 
)

Constructs a Sprite object, of the specified width and height. Frames are cut out from the given surface of the specified size.

Parameters:
surface 
width 
height 

ERY.AgateLib.Sprite.Sprite ( string  name,
ResourceManager  resources 
)

Constructs a Sprite object, loading it from the file specified in the given ResourceManager object.

Parameters:
name 
resources 


Member Function Documentation

Sprite ERY.AgateLib.Sprite.Clone (  ) 

Makes a copy of this sprite and returns it.

Returns:

void ERY.AgateLib.Sprite.Dispose (  ) 

Disposes of unmanaged resources associated with this sprite.

void ERY.AgateLib.Sprite.AddFrames ( string  filename  ) 

Slices and dices the image passed into frames and adds them. Automatically skips blank ones.

Parameters:
filename 

void ERY.AgateLib.Sprite.AddFrames ( Surface  surface  ) 

Adds frames from the given surface, using the size of this sprite.

Parameters:
surface 

void ERY.AgateLib.Sprite.AddFrames ( string  filename,
Point  startPoint,
Point  extraSpace,
bool  skipBlank 
)

Adds frames from the given filename, using the size of this sprite. Frames are taken from startPoint, and with extraSpace inbetween.

Parameters:
filename 
startPoint 
extraSpace 
skipBlank 

void ERY.AgateLib.Sprite.AddFrames ( Surface  surface,
Point  startPoint,
Point  extraSpace,
bool  skipBlank 
)

Adds frames from the given surface, using the size of this sprite. Frames are taken from startPoint, and with extraSpace inbetween.

Parameters:
surface 
startPoint 
extraSpace 
skipBlank 

void ERY.AgateLib.Sprite.AddFrames ( Surface  surface,
Point  startPoint,
Point  extraSpace,
Size  size,
bool  skipBlank 
)

Slices and dices the image passed into frames and adds them. Frames are taken from the surface from left to right.

Parameters:
surface The surface to use to split up into the sprite frames.
startPoint The starting point in pixels from which to parse frames.
size The size of the image to cut out for each frame
extraSpace How many extra pixels to insert between each frame.
skipBlank Whether or not blank frames should be automatically dropped.

void ERY.AgateLib.Sprite.AddFrames ( Surface  surface,
Point  startPoint,
Point  extraSpace,
Size  size,
Size  array 
)

Slices and dices the image passed into frames and adds them. Frames are taken from the surface from left to right.

Parameters:
surface The surface to use to split up into the sprite frames.
startPoint The starting point in pixels from which to parse frames.
size The size of the image to cut out for each frame
extraSpace How many extra pixels to insert between each frame.
array How many frames to cut out. eg. If array = {4, 1}, four sprites will be taken from left to right.

void ERY.AgateLib.Sprite.Draw ( Rectangle  destRect  ) 

Draw the sprite to the given destination rectangle. Overrides scaling settings.

Parameters:
destRect 

void ERY.AgateLib.Sprite.Draw ( int  destX,
int  destY 
)

Draws the sprite at the specified position on screen.

Parameters:
destX 
destY 

void ERY.AgateLib.Sprite.Draw ( float  destX,
float  destY 
)

Draws the sprite at the specified position on screen.

Parameters:
destX 
destY 

void ERY.AgateLib.Sprite.Draw ( Point  destPt  ) 

Draws the sprite at the specified position on screen.

Parameters:
destPt 

void ERY.AgateLib.Sprite.Draw ( PointF  destPt  ) 

Draws the sprite at the specified position on screen.

Parameters:
destPt 

void ERY.AgateLib.Sprite.DrawPoints ( Point[]  dest_pts  ) 

Draws the sprite at all the specified positions on screen.

Parameters:
dest_pts 

void ERY.AgateLib.Sprite.Draw (  ) 

Draws the sprite at the origin.

void ERY.AgateLib.Sprite.DrawRects ( Rectangle[]  dest_rects  ) 

Draws the sprite at the specified rectangles.

Parameters:
dest_rects 

void ERY.AgateLib.Sprite.SetScale ( double  x,
double  y 
)

Sets the scale of the sprite.

Parameters:
x 
y 

void ERY.AgateLib.Sprite.GetScale ( out double  x,
out double  y 
)

Gets the scale of the sprite.

Parameters:
x 
y 

void ERY.AgateLib.Sprite.IncrementRotationAngle ( double  radians  ) 

Increments the rotation angle by the specified number of radians.

Parameters:
radians 

void ERY.AgateLib.Sprite.IncrementRotationAngleDegrees ( double  degrees  ) 

Increments the rotation angle by the specified number of degrees.

Parameters:
degrees 

void ERY.AgateLib.Sprite.Update (  ) 

Updates the animation of the sprite, using the DeltaTime given by the Display object.

void ERY.AgateLib.Sprite.Update ( double  time_ms  ) 

Updates the animation of the sprite, using the given frame time.

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

void ERY.AgateLib.Sprite.AdvanceFrame (  ) 

Shows the next frame in the sequence. This pays attention to whether the animation is playing forwards or reverse.

void ERY.AgateLib.Sprite.StartAnimation (  ) 

Restarts the animation.

delegate void ERY.AgateLib.Sprite.SpriteEventHandler ( Sprite  sprite  ) 

Event handler type for sprite events.

Parameters:
sprite 


Member Data Documentation

event SpriteEventHandler ERY.AgateLib.Sprite.AnimationStopped

Event which is raised when the animation is stopped.

event SpriteEventHandler ERY.AgateLib.Sprite.AnimationStarted

Event which is raised when the animation is started.

event SpriteEventHandler ERY.AgateLib.Sprite.PlayDirectionChanged

Event which is raised when the play direction is changed, as in the PingPong type.


Property Documentation

bool ERY.AgateLib.Sprite.UseSpriteCache [static, get, set]

Bool which indicates whether sprite frames should be cached to disk after they've been cut out. Speed up loading if used.

string ERY.AgateLib.Sprite.SpriteCachePath [static, get, set]

Sets the path where SpriteFrames are saved, if the sprite cache is used.

int ERY.AgateLib.Sprite.SpriteWidth [get]

Gets width of the sprite.

int ERY.AgateLib.Sprite.SpriteHeight [get]

Gets height of the sprite.

Size ERY.AgateLib.Sprite.SpriteSize [get]

Gets the size of the sprite.

int ERY.AgateLib.Sprite.DisplayWidth [get, set]

Gets the width of the sprite when displayed.

int ERY.AgateLib.Sprite.DisplayHeight [get, set]

Gets the height of the sprite when displayed.

Size ERY.AgateLib.Sprite.DisplaySize [get, set]

Gets or sets the size of the sprite when displayed.

double ERY.AgateLib.Sprite.Alpha [get, set]

Gets or sets transparency value. 0.0 is completely transparent 1.0 is completely opaque.

double ERY.AgateLib.Sprite.RotationAngle [get, set]

Gets or sets the rotation angle in radians.

double ERY.AgateLib.Sprite.RotationAngleDegrees [get, set]

Gets or sets the rotation angle in degrees.

OriginAlignment ERY.AgateLib.Sprite.RotationCenter [get, set]

Gets or sets the center of rotation.

OriginAlignment ERY.AgateLib.Sprite.DisplayAlignment [get, set]

Gets or sets the interpretation of the position.

Color ERY.AgateLib.Sprite.Color [get, set]

Gets or sets the color of the sprite.

bool ERY.AgateLib.Sprite.Visible [get, set]

Gets or sets whether or not the sprite should be drawn when Draw is called.

double ERY.AgateLib.Sprite.TimePerFrame [get, set]

The amount of time each frame should display, in milliseconds.

int ERY.AgateLib.Sprite.CurrentFrameIndex [get, set]

The index of the current frame.

SpriteFrame ERY.AgateLib.Sprite.CurrentFrame [get]

Gets the currently displaying frame.

bool ERY.AgateLib.Sprite.PlayReverse [get, set]

Gets or sets a flag which indicates whether or not this animation plays in reverse instead.

AnimType ERY.AgateLib.Sprite.AnimationType [get, set]

Gets or sets an enum value indicating what type of animation is happening. Looping - The animation will play from beginning to end and then restart. PingPong - The animation will play from beginning to end and then from end to beginning (continuously). Once - The animation plays once, and then shows its first frame. OnceHoldLast - The animation plays once, and leaves the last frame on.

bool ERY.AgateLib.Sprite.Animating [get, set]

Gets or sets a flag which indicates: True if the animation is running. False if a single frame will be shown indefinitely.

List<SpriteFrame> ERY.AgateLib.Sprite.Frames [get]

Gets the list of SpriteFrame objects in this sprite.


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