Class cocos.sprite.Sprite

batch.cocosnode.CocosNode --+    
                            |    
          batch.BatchableNode --+
                                |
         pyglet.sprite.Sprite --+
                                |
                               Sprite

Sprites are sprites that can execute actions.

Example:

sprite = Sprite('grossini.png')

Nested Classes

  supported_classes
Sprites are sprites that can execute actions.

Methods

  __init__(self, image, position=(0,0), rotation=0, scale=1, opacity=255, color=(255,255,255), anchor=None)
Initialize the sprite
  draw(self)
Inherited from batch.BatchableNode: add, remove, set_batch

Instance Variables

  group
group.
  children_group
children group.
  position
position of the sprite in (x,y) coordinates
  rotation
rotation degrees of the sprite.
  scale
scale of the sprite where 1.0 the default value
  opacity
opacity of the sprite where 0 is transparent and 255 is solid
  color
color of the sprite in R,G,B format where 0,0,0 is black and 255,255,255 is white

Class Variables

  image_anchor_x = property(_get_anchor_x, _set_anchor_x)
  image_anchor_y = property(_get_anchor_y, _set_anchor_y)
  image_anchor = property(_get_anchor, _set_anchor)

Method Details

__init__

(Constructor) __init__(self, image, position=(0,0), rotation=0, scale=1, opacity=255, color=(255,255,255), anchor=None)
Initialize the sprite
Parameters:
image : string or image
name of the image resource or a pyglet image.
position : tuple
position of the anchor. Defaults to (0,0)
rotation : float
the rotation (degrees). Defaults to 0.
scale : float
the zoom factor. Defaults to 1.
opacity : int
the opacity (0=transparent, 255=opaque). Defaults to 255.
color : tuple
the color to colorize the child (RGB 3-tuple). Defaults to (255,255,255).
anchor : (float, float)
(x,y)-point from where the image will be positions, rotated and scaled in pixels. For example (image.width/2, image.height/2) is the center (default).

Instance Variable Details

group

group. XXX what is this?

children_group

children group. XXX what is this ?

rotation

rotation degrees of the sprite. Default: 0 degrees