Sprite Class Reference

Class that allows for the movment, scaling and rotation of 2D images. More...

#include <Graphics/Sprite.h>

Inherited by AnimatedSprite.

List of all members.

Public Member Functions

 Sprite ()
 Default constructor.
 Sprite (const char *file)
 Constructs a Sprite using the given file.
bool Load (const char *file)
 Sets the image the Sprite takes.
void SetAngle (float a)
 Sets angle of rotation for the Sprite.
void Rotate (float a)
 Increments the angle of rotation for the Sprite.
float Angle () const
 Gets the current angle of the Sprite.
void SetPosition (const Point2f &p)
 Sets the position of the Sprite.
void Move (const Point2f &p)
 Moves the position of the Sprite.
Point2f Position () const
 Gets the current position of the Sprite.
void SetTransparency (float t)
 Sets the opacity of the Sprite.
void Fade (float t)
 Fades the Sprite in and out.
float Transparency () const
 Gets the current transparency of the Sprite.
void SetSize (float w, float h)
 Sets the size of the Sprite.
void SetWidth (float w)
 Sets the width of the Sprite.
void SetHeight (float h)
 Sets the height of the Sprite.
void SetWidthUniform (float w)
 Sets the width of the Sprite and scales the height uniformly.
void SetHeightUniform (float h)
 Sets the height of the Sprite and scales the width uniformly.
void SetScale (float s)
 Sets the uniform scale of the Sprite.
void SetScale (float sx, float sy)
 Sets the nonuniform scale of the Sprite.
void Grow (float s)
 Scales the Sprite uniformly.
void Grow (float sx, float sy)
 Scales the Sprite non-uniformly.
void Scale (float &sx, float &sy) const
 Gets the scaling factors for the Sprite.
void GetDimensions (float &w, float &h) const
 Retrives the width and height of the Sprite.
float GetHeight () const
 Retrives the height of the Sprite.
float GetWidth () const
 Retrives the Width of the Sprite.
AABB GetBBox () const
 Computes the bounding box for the Sprite.
bool CanDraw () const
 Determines if the sprite is in a state where it can be drawn.
void Draw (Image::DrawLocation loc=Image::CENTER) const
 Draws the sprite.
void Draw (const Point2f &p, Image::DrawLocation loc=Image::CENTER) const
 Draws the sprite.
void DrawSubArea (const Rectf &area, Image::DrawLocation loc=Image::CENTER) const
 Draws a portion of the sprite.
void DrawSubArea (const Point2f &p, const Rectf &area, Image::DrawLocation loc=Image::CENTER) const
 Draws a portion of the sprite.
ImageRef GetImage ()
 Gets the image associated with the Sprite.

Detailed Description

Class that allows for the movment, scaling and rotation of 2D images.


Constructor & Destructor Documentation

Sprite::Sprite ( const char *  file  ) 

Constructs a Sprite using the given file.

Parameters:
[in] file the file name of the image to load.

Member Function Documentation

float Sprite::Angle (  )  const [inline]

Gets the current angle of the Sprite.

Returns:
The angle of the Sprite in radians.
bool Sprite::CanDraw (  )  const

Determines if the sprite is in a state where it can be drawn.

Returns:
True if the sprite can be drawn, flase otherwise.
void Sprite::Draw ( const Point2f p,
Image::DrawLocation  loc = Image::CENTER 
) const

Draws the sprite.

Parameters:
[in] pos the position to draw the sprite. Supersedes the position of the sprite.
[in] loc the locaation to draw the fixed point of the Sprite. Defaults to CENTER.
See also:
Image
void Sprite::Draw ( Image::DrawLocation  loc = Image::CENTER  )  const

Draws the sprite.

Parameters:
[in] loc the locaation to draw the fixed point of the Sprite. Defaults to CENTER.
See also:
Image
void Sprite::DrawSubArea ( const Point2f p,
const Rectf area,
Image::DrawLocation  loc = Image::CENTER 
) const

Draws a portion of the sprite.

Parameters:
[in] p the position to draw the sprite. Supersedes the position of the sprite.
[in] area the subregioin to draw from the sprite.
[in] loc the locaation to draw the fixed point of the Sprite. Defaults to CENTER.
See also:
Image
void Sprite::DrawSubArea ( const Rectf area,
Image::DrawLocation  loc = Image::CENTER 
) const

Draws a portion of the sprite.

Parameters:
[in] area the subregioin to draw from the sprite.
[in] loc the locaation to draw the fixed point of the Sprite. Defaults to CENTER.
See also:
Image
void Sprite::Fade ( float  t  ) 

Fades the Sprite in and out.

Parameters:
[in] t the amount to fade the transparency of the Sprite.
AABB Sprite::GetBBox (  )  const

Computes the bounding box for the Sprite.

Returns:
The AABB that bounds the Sprite.
void Sprite::GetDimensions ( float &  w,
float &  h 
) const [inline]

Retrives the width and height of the Sprite.

Parameters:
[out] w the width of the Sprite.
[out] h the height of the Sprite.
float Sprite::GetHeight (  )  const [inline]

Retrives the height of the Sprite.

Returns:
The height of the Sprite.
ImageRef Sprite::GetImage (  )  [inline]

Gets the image associated with the Sprite.

Returns:
The ImageRef used by the Sprite.
float Sprite::GetWidth (  )  const [inline]

Retrives the Width of the Sprite.

Returns:
The Width of the Sprite.
void Sprite::Grow ( float  sx,
float  sy 
)

Scales the Sprite non-uniformly.

Parameters:
[in] sx the amount to scale the Sprite along the x-axis.
[in] sy the amount to scale the Sprite along the y-axis.
void Sprite::Grow ( float  s  ) 

Scales the Sprite uniformly.

Parameters:
[in] s the amount to uniformly scaling the Sprite.
bool Sprite::Load ( const char *  file  ) 

Sets the image the Sprite takes.

Parameters:
[in] file the file name of the image to load.
Returns:
True if the image was loaded, false otherwise.
void Sprite::Move ( const Point2f p  ) 

Moves the position of the Sprite.

Parameters:
[in] p the amount to move the Sprite.
Point2f Sprite::Position (  )  const [inline]

Gets the current position of the Sprite.

Returns:
The current position of the Sprite.
void Sprite::Rotate ( float  a  ) 

Increments the angle of rotation for the Sprite.

Parameters:
[in] a the angle in radians.
void Sprite::Scale ( float &  sx,
float &  sy 
) const [inline]

Gets the scaling factors for the Sprite.

Parameters:
[out] sx the scaling factor along the x-axis.
[out] sy the scaling factor along the y-axis.
void Sprite::SetAngle ( float  a  ) 

Sets angle of rotation for the Sprite.

Parameters:
[in] a the angle in radians.
void Sprite::SetHeight ( float  h  ) 

Sets the height of the Sprite.

Parameters:
[in] h the desired height of the sprite

Computes the scale factor that make the loaded image have the given width.

void Sprite::SetHeightUniform ( float  h  ) 

Sets the height of the Sprite and scales the width uniformly.

Parameters:
[in] h the desired height of the sprite

Computes the scale factor that make the loaded image have the given height.

void Sprite::SetPosition ( const Point2f p  ) 

Sets the position of the Sprite.

Parameters:
[in] p the position of the Sprite.
void Sprite::SetScale ( float  sx,
float  sy 
)

Sets the nonuniform scale of the Sprite.

Parameters:
[in] sx the scaling factor along the x-axis, $s_x > 0$.
[in] sy the scaling factor along the y-axis, $s_y > 0$.
void Sprite::SetScale ( float  s  ) 

Sets the uniform scale of the Sprite.

Parameters:
[in] s the uniform scaling factor, $s > 0$.
void Sprite::SetSize ( float  w,
float  h 
)

Sets the size of the Sprite.

Parameters:
[in] w the desired width of the sprite
[in] h the desired height of the sprite

Computes the scale factors to make the loaded image have the given width and height.

void Sprite::SetTransparency ( float  t  ) 

Sets the opacity of the Sprite.

Parameters:
[in] t the transparency to set the Sprite. t should be in the range [0,1] where 0 is fully transparent and 1 is fully opaque.
void Sprite::SetWidth ( float  w  ) 

Sets the width of the Sprite.

Parameters:
[in] w the desired width of the sprite

Computes the scale factor that make the loaded image have the given width.

void Sprite::SetWidthUniform ( float  w  ) 

Sets the width of the Sprite and scales the height uniformly.

Parameters:
[in] w the desired width of the sprite

Computes the scale factor that make the loaded image have the given width.

float Sprite::Transparency (  )  const [inline]

Gets the current transparency of the Sprite.

Returns:
The current transparency of the Sprite.

The documentation for this class was generated from the following files:
Generated on Mon Apr 5 19:08:06 2010 for BrickOut |ReDuX| by  doxygen 1.6.3