Sprite

Inherited: None

Description

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

int

addElement (Texture * texture)

void

addPage (Texture * texture)

void

packSheets (int padding)

Texture *

page (int key = -1) const

void

setShape (int key, Mesh * mesh)

Mesh *

shape (int key) const

Static Methods

None

Methods Description

int Sprite::addElement (Texture * texture)

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.

See also packSheets().


void Sprite::addPage (Texture * texture)

Adds a new sprite sheet texture.


void Sprite::packSheets (int padding)

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

See also addElement().


Texture * Sprite::page (int key = -1) const

Returns a sprite sheet texture with key.


void Sprite::setShape (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 shape().


Mesh * Sprite::shape (int key) const

Returns a mesh which represents the sprite with key.

See also setShape().