Gel2D - The free/open source game creation suite

Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
gel::GelSprite Class Reference

Sprite. More...

#include <gelSprite.h>

Inheritance diagram for gel::GelSprite:
gel::GelObject gel::GelTextureObject gel::GelEventReceiver gel::GelAnimSprite

List of all members.

Public Member Functions

 GelSprite ()
 Default constructor.
 GelSprite (Gel2dVec obj_size, Gel2dVec obj_pos, float obj_rot)
 Convenience constructor.
void setSize (Gel2dVec size)
 Sets the size of the quad in pixels.
void flip (int axis)
 Flips the quad.
GelColor getCol (int i=0) const
 Gets the color of the specified vertex.
void setCol (GelColor col, int i=-1)
 Sets the color of the specified quad's vertex.
void setRGB (float r, float g, float b, int i=-1)
 Sets the color of the specified vertex in RGB values.
float getAlpha (int i=0) const
 Gets the transparency of the specified vertex.
void setAlpha (float alpha, int i=-1)
 Sets the transparency of the specified vertex.
void mapRect (const Gel2dVec &pos, const Gel2dVec &size)
void setTexture (GelTexture *tex)
 Sets the quad's texture.
void flipTexture (Orientation axis)
 Flips the quad's texture.
bool isTexFlipped (Orientation axis) const
 Checks if the quad's texture is flipped along a specified axis.
GelAABB getAABB () const
 Gets the quad's axis-aligned bounding box.
void render ()
 Renders the quad to the screen.

Public Attributes

GelVert v [4]
 The quad's vertices.

Protected Member Functions

int _pointIntersect (float locx, float locy)

Protected Attributes

int xFlip
int yFlip

Detailed Description

Sprite.


Constructor & Destructor Documentation

gel::GelSprite::GelSprite ( )

Default constructor.

gel::GelSprite::GelSprite ( Gel2dVec  obj_size,
Gel2dVec  obj_pos,
float  obj_rot 
)

Convenience constructor.

Parameters:
obj_size: A vector of the quad's width and height in pixels.
obj_pos: A vector of the quad's x and y coordinates in pixels.
obj_rot: The rotation of the quad in degrees.

Member Function Documentation

void gel::GelSprite::setSize ( Gel2dVec  size)

Sets the size of the quad in pixels.

Please note that the visual size of the quad is dependent on the object's scale. Even if the quad's size is set to, let's say, 48 pixels, it may appear to be a different size when rendered to the screen if the scale of the object is set to anything other than 1.0f.

Parameters:
size: A vector of the new width and height of the quad.
void gel::GelSprite::flip ( int  axis)

Flips the quad.

Parameters:
axis: The axis along which to flip the quad.
Can be either GEL_HOR or GEL_VERT.
GelColor gel::GelSprite::getCol ( int  i = 0) const

Gets the color of the specified vertex.

Parameters:
i: The vertex to get the color of. If omitted, selects the quad's first vertex.
Returns:
The color of the specified vertex.
void gel::GelSprite::setCol ( GelColor  col,
int  i = -1 
)

Sets the color of the specified quad's vertex.

Parameters:
col: The new color.
i: The vertex to apply the color to. If -1 or omitted, applies to all vertices.
void gel::GelSprite::setRGB ( float  r,
float  g,
float  b,
int  i = -1 
)

Sets the color of the specified vertex in RGB values.

Parameters:
r: New red value.
g: New green value.
b: New blue value.
i: The vertex to apply the color to. If -1 or omitted, applies to all vertices.
float gel::GelSprite::getAlpha ( int  i = 0) const

Gets the transparency of the specified vertex.

Parameters:
i: The vertex to get the alpha value of. If omitted, selects the quad's first vertex.
Returns:
The alpha of the specified vertex.
void gel::GelSprite::setAlpha ( float  alpha,
int  i = -1 
)

Sets the transparency of the specified vertex.

It should be in range from 0 (transparent) to 1 (opaque).

Parameters:
alpha: The new alpha value.
i: The vertex to apply the alpha to. If -1 or omitted, applies to all vertices.
void gel::GelSprite::mapRect ( const Gel2dVec pos,
const Gel2dVec size 
)
void gel::GelSprite::setTexture ( GelTexture tex)

Sets the quad's texture.

Parameters:
tex: The quad's new texture.
void gel::GelSprite::flipTexture ( Orientation  axis)

Flips the quad's texture.

Parameters:
axis: The axis along which to flip the texture.
bool gel::GelSprite::isTexFlipped ( Orientation  axis) const

Checks if the quad's texture is flipped along a specified axis.

Parameters:
axis: The axis you want to check.
GelAABB gel::GelSprite::getAABB ( ) const [virtual]

Gets the quad's axis-aligned bounding box.

Reimplemented from gel::GelObject.

void gel::GelSprite::render ( ) [virtual]

Renders the quad to the screen.

Reimplemented from gel::GelObject.

Reimplemented in gel::GelAnimSprite.

int gel::GelSprite::_pointIntersect ( float  locx,
float  locy 
) [protected, virtual]

Reimplemented from gel::GelObject.


Member Data Documentation

The quad's vertices.

int gel::GelSprite::xFlip [protected]
int gel::GelSprite::yFlip [protected]

The documentation for this class was generated from the following file: