Shaku

Shaku JS

Back To Table of Content

Sprites Group

SpritesGroup

Sprites group class. This object is a container to hold sprites collection + parent transformations. You need SpritesGroup to use batched rendering.

Kind: global class

new SpritesGroup()

Create the group object.

spritesGroup.count ⇒ Number

Sprites count in group.

Kind: instance property of SpritesGroup
Returns: Number - Number of sprites in group.

spritesGroup.forEach(callback)

Iterate all sprites.

Kind: instance method of SpritesGroup

Param Type Description
callback function Callback to run on all sprites in group.

spritesGroup.setColor(color)

Set color for all sprites in group.

Kind: instance method of SpritesGroup

Param Type Description
color Color Color to set.

spritesGroup.getTransform() ⇒ Matrix

Get group’s transformations.

Kind: instance method of SpritesGroup
Returns: Matrix - Transformations matrix, or null if there’s nothing to apply.

spritesGroup.add(sprite) ⇒ Sprite

Adds a sprite to group.

Kind: instance method of SpritesGroup
Returns: Sprite - The newly added sprite.

Param Type Description
sprite Sprite Sprite to add.

spritesGroup.remove(sprite)

Remove a sprite from group.

Kind: instance method of SpritesGroup

Param Type Description
sprite Sprite Sprite to remove.

spritesGroup.shift() ⇒ Sprite

Shift first sprite element.

Kind: instance method of SpritesGroup
Returns: Sprite - The removed sprite.

spritesGroup.sort(compare)

Sort sprites.

Kind: instance method of SpritesGroup

Param Type Description
compare function Comparer method.