AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
A sprite is the visual representation of an on screen game object. More...
#include <CzSprite.h>
Public Types | |
enum | eType { ST_None, ST_Image, ST_Text, ST_Dummy, ST_9Patch, ST_Poly } |
Values that represent the type of sprite to render. More... | |
enum | eAnchor { Centre, TopLeft } |
typedef CzList< CzSprite * > ::iterator | Iterator |
Public Member Functions | |
Iterator | begin () |
Iterator | end () |
void | setActor (CzActor *owner) |
void | setParent (CzSprite *parent) |
CzSprite * | getParent () |
void | addChild (CzSprite *sprite) |
Adds a child sprite to the sprites child list. | |
void | removeChild (CzSprite *sprite, bool delete_sprites=true) |
Removes a child sprite from teh child list and optionally destroys it. | |
void | setSpriteType (eType type) |
eType | getSpriteType () const |
void | setManager (CzSpriteManager *manager) |
CzSpriteManager * | getManager () |
void | setDestSize (int width, int height) |
void | setDepth (float depth) |
float | getDestWidth () const |
float | getDestHeight () const |
CzVec2 | getDestSize () const |
float | getDepth () const |
void | setPosAngScale (float x, float y, float angle, float scale) |
void | setPosAngScale (float x, float y, float angle, float scale_x, float scale_y) |
void | setPosition (float x, float y) |
CzVec2 | getPosition () const |
void | setOrigin (float x, float y) |
CzVec2 | getOrigin () const |
void | setSkew (float x1, float x2, float y1, float y2) |
CzVec4 | getSkew () const |
void | setAngle (float angle) |
float | getAngle () const |
void | setScale (float scale) |
void | setScale (float scale_x, float scale_y) |
float | getScale () const |
float | getScaleX () const |
float | getScaleY () const |
virtual void | setColour (const CzColour &colour, bool use_parent=false) |
CzColour | getColour () const |
int | getOpacity () const |
void | setVisible (bool show) |
bool | isVisible () const |
void | setFilter (bool enable) |
bool | isFilter () const |
bool | isVisibleWithParents () const |
Checks up the sprite hierarchy to see if the sprite and its parents are visible. | |
void | forceTransformDirty () |
void | setPooled (bool pooled) |
bool | isPooled () const |
void | setInUse (bool in_use) |
bool | isInUse () const |
void | setLayer (int layer) |
int | getLayer () const |
CzMatrix3 & | getTransform () |
void | setLinkedTo (CzSprite *sprite) |
Changes sprite linkage. | |
CzSprite * | getLinkedTo () |
float | getAccumDepth () const |
bool | isTransformDirty () const |
IzBrush * | getBrush () |
int | getVertexCount () const |
void | setClipRect (CzVec4 &rc) |
Sets the sprites clip rectangle. | |
CzVec4 | getClipRect () const |
CzVec4 | getScreenClipRect () const |
void | setBeforeChildren (bool before) |
bool | getBeforeChildren () const |
CzMatrix3 & | getFinalTransform () |
bool | affectsClip () const |
CzVec4 | FindFirstClipRect () |
Searches up the sprite hierarchy for the first clip rectangle. | |
CzVec4 | FindFirstScreenClipRect () |
Searches up the sprite hierarchy for the first valid screen clip rectangle. | |
CzVec4 | FindFirstScreenClipRect2 () |
Searches up the sprite hierarchy for the first valid screen clip rectangle. | |
virtual bool | isClipped () |
Query if this sprite is clipped. | |
CzVec2 * | getScreenV () |
void | setAlphaMode (eCzAlphaMode mode) |
eCzAlphaMode | getAlphaMode () const |
void | setOrphan (bool enable) |
bool | getOrphan () const |
void | setIgnoreCamera (bool enable) |
bool | getIgnoreCamera () const |
void | setTiled (bool tiled) |
bool | isTiled () const |
CzRenderPrim * | getPrim () |
CzRenderMaterial * | getMaterial () |
eAnchor | getAnchor () const |
void | setAnchor (eAnchor anchor) |
CzGeometry * | getGemoetry () |
virtual void | setGeometry (CzGeometry *geom) |
Sets the sprites geometry. The geometry defines what shape will be rendered by the sprite. | |
CzSprite () | |
virtual | ~CzSprite () |
virtual void | Init (int vertex_count=4) |
Initialises the sprite. | |
virtual bool | Update () |
Updates the sprite and any child sprites. | |
virtual void | Draw ()=0 |
virtual void | DrawChildren () |
Draw the sprites child sprites. | |
virtual bool | HitTest (float x, float y) |
Tests if an x.y point is within the sprites boundaries. | |
virtual bool | HitTestNoClip (float x, float y) |
Tests if an x.y point is within the sprites boundaries. | |
virtual bool | isOutsideFocusRange (float x, float y, float scale=1.0f) |
Tests to see if the supplied point is outside a specific distance. | |
virtual CzVec2 | TransformPoint (float x, float y) |
Transform supplied point by current sprite transform. | |
virtual CzVec2 | TransformPointToScreen (float x, float y) |
Transform supplied point by current sprite final transform (to screen coordinates). | |
void | BringToFront () |
Bring sprite to front of other sprites. | |
virtual void | RebuildTransformNow () |
Rebuild the sprites transform immediately (if dirty). | |
bool | isClippedByManager (uint16 *indices=NULL, int count=4) |
Checks to see if the sprite is clipped by the sprite manager. | |
virtual bool | SimpleTestOverlap (CzSprite *other) |
A simple method to test for overlapping sprites. | |
virtual bool | TestOverlap (CzSprite *other, int i1, int i2, int i3) |
Tests if the supplied triangular area of the sprite overlaps this sprite. | |
virtual bool | TestOverlap (CzSprite *other) |
Tests for the overlapping of two sprites. | |
Static Public Attributes | |
static uint16 | SpriteIndices [] = { 0, 3, 1, 2 } |
Protected Member Functions | |
void | TransformClipRect () |
Transforms the local clipping rect to screen coords. | |
virtual void | RebuildTransform () |
Rebuilds the display transform. | |
virtual void | BuildFinalTransform () |
Buiolds the final transform. | |
virtual void | TransformVertices () |
Builds a list of transformed vertices. | |
void | UpdateClipping () |
Updates the gobal clipper to the sprites currenmt clipping rect. | |
Protected Attributes | |
CzActor * | Actor |
The actor that this sprite is attached to. | |
CzGeometry * | Geometry |
Geometry used to display the sprite. | |
CzSprite * | Parent |
Parent sprite. | |
CzList< CzSprite * > | Children |
List of children sprites. | |
eType | SpriteType |
Type of sprite. | |
CzSpriteManager * | Manager |
Parent sprite manager. | |
float | Width |
float | Height |
Destination width and height (used to represent the visible extents of the sprite on screen) | |
float | Depth |
Depth. | |
CzMatrix3 | Transform |
Transform. | |
CzVec2 | Position |
Position of the sprite. | |
CzVec2 | Origin |
Origin of sprite (0, 0 is sprites centre) | |
CzVec4 | Skew |
4 vertex skew offsets (3 bit fixed) | |
float | Angle |
Rotation of sprite (degrees) | |
float | ScaleX |
X axis scale of sprite. | |
float | ScaleY |
X axis scale of sprite. | |
CzColour | Colour |
Colour of sprite. | |
bool | Visible |
Sprites visible state. | |
bool | Pooled |
Tells system if we belong to a sprite pool or not. | |
bool | InUse |
Used in a memory pooling system to mark this sprite as in use. | |
bool | BeforeChildren |
When true th parent sprite will be drawn before all children otherwise after. | |
int | Layer |
Depth layer. | |
CzSprite * | LinkedTo |
When a sprite is linked to another it takes on that sprites transform etc.. | |
IzBrush * | Brush |
Current brush assigned to this sprite. | |
CzVec4 | ClipRect |
Local clipping rect used to clip this sprites children. | |
bool | Orphan |
When set to true sprites are orphaned outside the usual parent / child hierarchy and layered as independent objects. | |
bool | IgnoreCamera |
When set to true sprite ignores camera transform. | |
eAnchor | Anchor |
Position the sprite is anchored around. | |
bool | ChildChangeClip |
Set to true if child changes clip rect. | |
CzMatrix3 | FinalTransform |
Final transform. | |
bool | TransformDirty |
Dirty when transform changed. | |
CzRenderPrim * | Prim |
2D renderer primitive used to render this sprite | |
CzRenderMaterial * | Material |
Material used to render this sprite. | |
float | AccumDepth |
Accumulated depth. | |
CzVec4 | ScreenClipRect |
Transformed screen clipping rect for this sprite. |
A sprite is the visual representation of an on screen game object.
Can be thought of as an interface rather than a concrete class as other sprite types are created from this.
typedef CzList<CzSprite*>::iterator CzSprite::Iterator |
enum CzSprite::eAnchor |
enum CzSprite::eType |
Values that represent the type of sprite to render.
CzSprite::CzSprite | ( | ) | [inline] |
CzSprite::~CzSprite | ( | ) | [virtual] |
void CzSprite::addChild | ( | CzSprite * | sprite | ) |
Adds a child sprite to the sprites child list.
[in,out] | sprite | If non-null, the sprite. |
bool CzSprite::affectsClip | ( | ) | const [inline] |
Iterator CzSprite::begin | ( | ) | [inline] |
void CzSprite::BringToFront | ( | ) |
Bring sprite to front of other sprites.
If sprite is assigned to a manager then it will be ulinked and relinked back into the manager so that it will be drawn last. If the sprite is assigned as a child of another sprite then it will be ulinked and relinked back into the sprites child list so it will be the last drawn sprite in its parents sprite list.
void CzSprite::BuildFinalTransform | ( | ) | [protected, virtual] |
Buiolds the final transform.
Builds the sprites final transform.
The sprites local transform is combined with the sprite managers transform to create a final transform that transforms the sprite from its local sprite coordinates to screen coordinates.
Note that if the sprite has depth then basic perspective projection will be applied to the sprites position.
virtual void CzSprite::Draw | ( | ) | [pure virtual] |
Implemented in CzBitmapSprite, CzTextSprite, CzBitmapSprite9, CzBitmapPoly, and CzDummySprite.
void CzSprite::DrawChildren | ( | ) | [virtual] |
Draw the sprites child sprites.
Iterator CzSprite::end | ( | ) | [inline] |
Searches up the sprite hierarchy for the first clip rectangle.
Searches up the sprite hierarchy for the first valid screen clip rectangle.
This method does not check the current sprites screen clip rect.
Searches up the sprite hierarchy for the first valid screen clip rectangle.
This method will check the current sprites screen clip rect
void CzSprite::forceTransformDirty | ( | ) | [inline] |
float CzSprite::getAccumDepth | ( | ) | const [inline] |
eCzAlphaMode CzSprite::getAlphaMode | ( | ) | const [inline] |
eAnchor CzSprite::getAnchor | ( | ) | const [inline] |
float CzSprite::getAngle | ( | ) | const [inline] |
bool CzSprite::getBeforeChildren | ( | ) | const [inline] |
IzBrush* CzSprite::getBrush | ( | ) | [inline] |
CzVec4 CzSprite::getClipRect | ( | ) | const [inline] |
CzColour CzSprite::getColour | ( | ) | const [inline] |
float CzSprite::getDepth | ( | ) | const [inline] |
float CzSprite::getDestHeight | ( | ) | const [inline] |
CzVec2 CzSprite::getDestSize | ( | ) | const [inline] |
float CzSprite::getDestWidth | ( | ) | const [inline] |
CzMatrix3& CzSprite::getFinalTransform | ( | ) | [inline] |
CzGeometry* CzSprite::getGemoetry | ( | ) | [inline] |
bool CzSprite::getIgnoreCamera | ( | ) | const [inline] |
int CzSprite::getLayer | ( | ) | const [inline] |
CzSprite* CzSprite::getLinkedTo | ( | ) | [inline] |
CzSpriteManager* CzSprite::getManager | ( | ) | [inline] |
CzRenderMaterial* CzSprite::getMaterial | ( | ) | [inline] |
int CzSprite::getOpacity | ( | ) | const [inline] |
CzVec2 CzSprite::getOrigin | ( | ) | const [inline] |
bool CzSprite::getOrphan | ( | ) | const [inline] |
CzSprite* CzSprite::getParent | ( | ) | [inline] |
CzVec2 CzSprite::getPosition | ( | ) | const [inline] |
CzRenderPrim* CzSprite::getPrim | ( | ) | [inline] |
float CzSprite::getScale | ( | ) | const [inline] |
float CzSprite::getScaleX | ( | ) | const [inline] |
float CzSprite::getScaleY | ( | ) | const [inline] |
CzVec4 CzSprite::getScreenClipRect | ( | ) | const [inline] |
CzVec2* CzSprite::getScreenV | ( | ) | [inline] |
CzVec4 CzSprite::getSkew | ( | ) | const [inline] |
eType CzSprite::getSpriteType | ( | ) | const [inline] |
CzMatrix3& CzSprite::getTransform | ( | ) | [inline] |
int CzSprite::getVertexCount | ( | ) | const [inline] |
bool CzSprite::HitTest | ( | float | x, |
float | y | ||
) | [virtual] |
Tests if an x.y point is within the sprites boundaries.
Note that this method will automatically fail if the x,y point is outside the sprite managers clipping window rect.
x | The x coordinate. |
y | The y coordinate. |
Reimplemented in CzBitmapSprite9, and CzBitmapPoly.
bool CzSprite::HitTestNoClip | ( | float | x, |
float | y | ||
) | [virtual] |
Tests if an x.y point is within the sprites boundaries.
This method does not take into accuont any cliping rects that are assigned to the sprites manager.
x | The x coordinate. |
y | The y coordinate. |
Reimplemented in CzBitmapSprite9, and CzBitmapPoly.
void CzSprite::Init | ( | int | vertex_count = 4 | ) | [virtual] |
Initialises the sprite.
vertex_count | Number of vertices that the sprite is made up from. |
Reimplemented in CzBitmapSprite, CzTextSprite, and CzBitmapSprite9.
bool CzSprite::isClipped | ( | ) | [virtual] |
Query if this sprite is clipped.
Reimplemented in CzBitmapSprite9, and CzBitmapPoly.
bool CzSprite::isClippedByManager | ( | uint16 * | indices = NULL , |
int | count = 4 |
||
) |
Checks to see if the sprite is clipped by the sprite manager.
Utility method that checks the sprites current transformed vertices and the order defined by the supplied vertex indices list to see if they are fully clipped.
[in] | indices | If non-null, the sprites vertex indices. |
count | Number of vertices. |
bool CzSprite::isFilter | ( | ) | const [inline] |
bool CzSprite::isInUse | ( | ) | const [inline] |
bool CzSprite::isOutsideFocusRange | ( | float | x, |
float | y, | ||
float | scale = 1.0f |
||
) | [virtual] |
Tests to see if the supplied point is outside a specific distance.
The focus range is the distance that a point has to move to to be declared as no longer having touch focus. The default focus range is calculated as the longest distance between each end of the sprite. The supplied scale value can be used to increase the focus range. For example a scale value of 2.0 will increase the focus range to double the size of the sprites visible dimensions.
x | The x coordinate. |
y | The y coordinate. |
scale | The amount to scale the focus range. |
Reimplemented in CzBitmapSprite9.
bool CzSprite::isPooled | ( | ) | const [inline] |
bool CzSprite::isTiled | ( | ) | const [inline] |
bool CzSprite::isTransformDirty | ( | ) | const [inline] |
bool CzSprite::isVisible | ( | ) | const [inline] |
bool CzSprite::isVisibleWithParents | ( | ) | const |
Checks up the sprite hierarchy to see if the sprite and its parents are visible.
void CzSprite::RebuildTransform | ( | ) | [protected, virtual] |
Rebuilds the display transform.
Rebuilds the sprites display transform.
Reimplemented in CzTextSprite.
void CzSprite::RebuildTransformNow | ( | ) | [virtual] |
Rebuild the sprites transform immediately (if dirty).
void CzSprite::removeChild | ( | CzSprite * | sprite, |
bool | delete_sprites = true |
||
) |
Removes a child sprite from teh child list and optionally destroys it.
[in] | sprite | If non-null, the sprite. |
delete_sprites | true to delete the sprites. |
void CzSprite::setActor | ( | CzActor * | owner | ) | [inline] |
void CzSprite::setAlphaMode | ( | eCzAlphaMode | mode | ) | [inline] |
void CzSprite::setAnchor | ( | eAnchor | anchor | ) | [inline] |
void CzSprite::setAngle | ( | float | angle | ) | [inline] |
void CzSprite::setBeforeChildren | ( | bool | before | ) | [inline] |
void CzSprite::setClipRect | ( | CzVec4 & | rc | ) |
Sets the sprites clip rectangle.
[in,out] | rc | The clip rectangle. |
virtual void CzSprite::setColour | ( | const CzColour & | colour, |
bool | use_parent = false |
||
) | [inline, virtual] |
Reimplemented in CzBitmapSprite.
void CzSprite::setDepth | ( | float | depth | ) | [inline] |
void CzSprite::setDestSize | ( | int | width, |
int | height | ||
) | [inline] |
void CzSprite::setFilter | ( | bool | enable | ) | [inline] |
void CzSprite::setGeometry | ( | CzGeometry * | geom | ) | [virtual] |
Sets the sprites geometry. The geometry defines what shape will be rendered by the sprite.
[in] | geom | If non-null, the geometry. |
Reimplemented in CzBitmapSprite.
void CzSprite::setIgnoreCamera | ( | bool | enable | ) | [inline] |
void CzSprite::setInUse | ( | bool | in_use | ) | [inline] |
void CzSprite::setLayer | ( | int | layer | ) | [inline] |
void CzSprite::setLinkedTo | ( | CzSprite * | sprite | ) |
Changes sprite linkage.
Sprites by default are placed in the sprite manager. When a sprite is linked to another sprite it is removed from the sprite manager and added to that sprites child list unless it is an orphan sprite.
[in,out] | sprite | If non-null, the sprite. |
void CzSprite::setManager | ( | CzSpriteManager * | manager | ) | [inline] |
void CzSprite::setOrigin | ( | float | x, |
float | y | ||
) | [inline] |
void CzSprite::setOrphan | ( | bool | enable | ) | [inline] |
void CzSprite::setParent | ( | CzSprite * | parent | ) | [inline] |
void CzSprite::setPooled | ( | bool | pooled | ) | [inline] |
void CzSprite::setPosAngScale | ( | float | x, |
float | y, | ||
float | angle, | ||
float | scale | ||
) | [inline] |
void CzSprite::setPosAngScale | ( | float | x, |
float | y, | ||
float | angle, | ||
float | scale_x, | ||
float | scale_y | ||
) | [inline] |
void CzSprite::setPosition | ( | float | x, |
float | y | ||
) | [inline] |
void CzSprite::setScale | ( | float | scale | ) | [inline] |
void CzSprite::setScale | ( | float | scale_x, |
float | scale_y | ||
) | [inline] |
void CzSprite::setSkew | ( | float | x1, |
float | x2, | ||
float | y1, | ||
float | y2 | ||
) | [inline] |
void CzSprite::setSpriteType | ( | eType | type | ) | [inline] |
void CzSprite::setTiled | ( | bool | tiled | ) | [inline] |
void CzSprite::setVisible | ( | bool | show | ) | [inline] |
bool CzSprite::SimpleTestOverlap | ( | CzSprite * | other | ) | [virtual] |
A simple method to test for overlapping sprites.
Note that this nethod does not take into account rotation.
[in] | other | If non-null, the other sprite. |
Reimplemented in CzBitmapSprite9, and CzBitmapPoly.
bool CzSprite::TestOverlap | ( | CzSprite * | other, |
int | i1, | ||
int | i2, | ||
int | i3 | ||
) | [virtual] |
Tests if the supplied triangular area of the sprite overlaps this sprite.
Using 3 vertices at the supplied indices i1, i2, i3 of the supplied sprites transformed vertices to see if the overlap this sprites vertices.
Note that this method can also test against 16 vertex patch sprites
[in] | other | If non-null, the other. |
i1 | First vertex index. | |
i2 | Second vertex index. | |
i3 | Third vertex index. |
Reimplemented in CzBitmapSprite9.
bool CzSprite::TestOverlap | ( | CzSprite * | other | ) | [virtual] |
Tests for the overlapping of two sprites.
This method takes into account rotation of both sprites. However, it will revert to a simple method of overlap testing if both sprites are not rotated.
[in,out] | other | If non-null, the other sprite. |
Reimplemented in CzBitmapSprite9, and CzBitmapPoly.
void CzSprite::TransformClipRect | ( | ) | [protected] |
Transforms the local clipping rect to screen coords.
Transform the sprites clipping rectangle.
CzVec2 CzSprite::TransformPoint | ( | float | x, |
float | y | ||
) | [virtual] |
Transform supplied point by current sprite transform.
x | The x coordinate. |
y | The y coordinate. |
CzVec2 CzSprite::TransformPointToScreen | ( | float | x, |
float | y | ||
) | [virtual] |
Transform supplied point by current sprite final transform (to screen coordinates).
x | The x coordinate. |
y | The y coordinate. |
void CzSprite::TransformVertices | ( | ) | [protected, virtual] |
Builds a list of transformed vertices.
Transform sprites vertices by current sprite transform.
Reimplemented in CzTextSprite, CzBitmapSprite9, and CzBitmapPoly.
bool CzSprite::Update | ( | ) | [virtual] |
Updates the sprite and any child sprites.
void CzSprite::UpdateClipping | ( | ) | [protected] |
Updates the gobal clipper to the sprites currenmt clipping rect.
float CzSprite::AccumDepth [protected] |
Accumulated depth.
CzActor* CzSprite::Actor [protected] |
The actor that this sprite is attached to.
eAnchor CzSprite::Anchor [protected] |
Position the sprite is anchored around.
float CzSprite::Angle [protected] |
Rotation of sprite (degrees)
bool CzSprite::BeforeChildren [protected] |
When true th parent sprite will be drawn before all children otherwise after.
IzBrush* CzSprite::Brush [protected] |
Current brush assigned to this sprite.
bool CzSprite::ChildChangeClip [protected] |
Set to true if child changes clip rect.
CzList<CzSprite*> CzSprite::Children [protected] |
List of children sprites.
CzVec4 CzSprite::ClipRect [protected] |
Local clipping rect used to clip this sprites children.
CzColour CzSprite::Colour [protected] |
Colour of sprite.
float CzSprite::Depth [protected] |
Depth.
CzMatrix3 CzSprite::FinalTransform [protected] |
Final transform.
CzGeometry* CzSprite::Geometry [protected] |
Geometry used to display the sprite.
Reimplemented in CzBitmapPoly.
float CzSprite::Height [protected] |
Destination width and height (used to represent the visible extents of the sprite on screen)
bool CzSprite::IgnoreCamera [protected] |
When set to true sprite ignores camera transform.
bool CzSprite::InUse [protected] |
Used in a memory pooling system to mark this sprite as in use.
int CzSprite::Layer [protected] |
Depth layer.
CzSprite* CzSprite::LinkedTo [protected] |
When a sprite is linked to another it takes on that sprites transform etc..
CzSpriteManager* CzSprite::Manager [protected] |
Parent sprite manager.
CzRenderMaterial* CzSprite::Material [protected] |
Material used to render this sprite.
CzVec2 CzSprite::Origin [protected] |
Origin of sprite (0, 0 is sprites centre)
bool CzSprite::Orphan [protected] |
When set to true sprites are orphaned outside the usual parent / child hierarchy and layered as independent objects.
CzSprite* CzSprite::Parent [protected] |
Parent sprite.
bool CzSprite::Pooled [protected] |
Tells system if we belong to a sprite pool or not.
CzVec2 CzSprite::Position [protected] |
Position of the sprite.
CzRenderPrim* CzSprite::Prim [protected] |
2D renderer primitive used to render this sprite
float CzSprite::ScaleX [protected] |
X axis scale of sprite.
float CzSprite::ScaleY [protected] |
X axis scale of sprite.
CzVec4 CzSprite::ScreenClipRect [protected] |
Transformed screen clipping rect for this sprite.
CzVec4 CzSprite::Skew [protected] |
4 vertex skew offsets (3 bit fixed)
uint16 CzSprite::SpriteIndices = { 0, 3, 1, 2 } [static] |
eType CzSprite::SpriteType [protected] |
Type of sprite.
CzMatrix3 CzSprite::Transform [protected] |
Transform.
bool CzSprite::TransformDirty [protected] |
Dirty when transform changed.
bool CzSprite::Visible [protected] |
Sprites visible state.
float CzSprite::Width [protected] |