Module cocos.sprite

Sprites allows to display a image in a rectangular area, which can be rotated, scaled and moved. The placement in the scene follows the standard CocosNode rules. Also, all stock actions will work with sprites.

Animating a sprite

Animation as in cartoon style animation, that is, replacing the image fast enough to give the illusion of movement, can be accomplished by:

Changing a sprite by way of actions

To execute any action you need to create an action:

move = MoveBy( (50,0), 5 )

In this case, move is an action that will move the sprite 50 pixels to the right (x coordinate) and 0 pixel in the y coordinate in 5 seconds.

And now tell the sprite to execute it:

sprite.do( move )

Classes

  Sprite
A CocosNode that displays a rectangular image.