Inherited: Resource


Sprites usually used in games to display environment and characters in 2D games. This class also supports sprite sheets to contain several images in one container to simplify animation or handle tile maps.

Public Methods


addElement (Texture * texture, const std::string & name = …)

Mesh *

mesh (int key) const


pack (int padding)


setMesh (int key, Mesh * mesh)


setTexture (Texture * texture)

Texture *

texture () const

Static Methods


Methods Description

int Sprite::addElement (Texture * texture, std::string & name = …)

Adds new sub texture as element to current sprite sheet. All elements will be packed to a single sprite sheet texture using Sprite::pack() method. Returns the id of the new element. Optionally developer is able to provide a name of element. In this case method will return a hash of provided name.

See also pack().

:ref:`Mesh<api_Mesh>`* Sprite::mesh (int key) const

Returns a mesh which represents the sprite with key.

See also setMesh().

void Sprite::pack (int padding)

Packs all added elements int to a single sprite sheet. Parameter padding can be used to delimit elements.

See also addElement().

void Sprite::setMesh (int key, Mesh * mesh)

Sets a new mesh for the sprite with key. The old mesh will be deleted and no longer available.

See also *mesh*().

void Sprite::setTexture (Texture * texture)

Sets a new sprite sheet texture.

See also *texture*().

:ref:`Texture<api_Texture>`* Sprite::texture () const

Returns a sprite sheet texture.

See also setTexture().