cocos :: sprite :: Sprite :: Class Sprite
[hide private]
[frames] | no frames]

Class Sprite

   batch.cocosnode.CocosNode --+    
                               |    
             batch.BatchableNode --+
                                   |
                  object --+       |
                           |       |
pyglet.event.EventDispatcher --+   |
                               |   |
            pyglet.sprite.Sprite --+
                                   |
                                  Sprite

A CocosNode that displays a rectangular image.

Example::

    sprite = Sprite('grossini.png')

Nested Classes [hide private]
  supported_classes
A CocosNode that displays a rectangular image.
Instance Methods [hide private]
 
__init__(self, image, position=(0,0), rotation=0, scale=1, opacity=255, color=(255,255,255), anchor=None)
Initialize the sprite
 
get_rect(self)
Get a cocos.rect.Rect for this sprite.
 
get_AABB(self)
Returns a local-coordinates Axis aligned Bounding Box
 
_set_rotation(self, a)
 
_set_scale(self, s)
 
_set_position(self, p)
 
_set_x(self, x)
 
_set_y(self, y)
 
contains(self, x, y)
Test whether this (untransformed) Sprite contains the pixel coordinates given.
 
_set_anchor_x(self, value)
 
_get_anchor_x(self)
 
_set_anchor_y(self, value)
 
_get_anchor_y(self)
 
_set_anchor(self, value)
 
_get_anchor(self)
 
draw(self)
When the sprite is not into a batch it will be draw with this method.
 
_update_position(self)
updates vertex list

Inherited from batch.BatchableNode: add, remove, set_batch

Inherited from pyglet.sprite.Sprite: __del__, delete, on_animation_end, set_position

Inherited from pyglet.sprite.Sprite (private): _animate, _create_vertex_list, _get_batch, _get_group, _get_image, _set_batch, _set_color, _set_group, _set_image, _set_opacity, _set_texture, _set_visible, _update_color

Inherited from pyglet.event.EventDispatcher: dispatch_event, event, pop_handlers, push_handlers, remove_handler, remove_handlers, set_handler, set_handlers

Inherited from pyglet.event.EventDispatcher (private): _get_handlers, _raise_dispatch_exception

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]

Inherited from pyglet.event.EventDispatcher: register_event_type

Class Variables [hide private]
  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)

Inherited from pyglet.sprite.Sprite: batch, color, group, height, image, opacity, position, rotation, scale, visible, width, x, y

Inherited from pyglet.sprite.Sprite (private): _animation, _batch, _opacity, _rgb, _rotation, _scale, _vertex_list, _visible

Inherited from pyglet.event.EventDispatcher (private): _event_stack

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, image, position=(0,0), rotation=0, scale=1, opacity=255, color=(255,255,255), anchor=None)
(Constructor)

 
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).

Overrides: object.__init__

get_rect(self)

 
Get a cocos.rect.Rect for this sprite.

Note that this rect's position is most likely NOT the same
as the Sprite's position - in fact by default the rect's
center is the Sprite's position. If you move the rect around
and wish to reflect this change in the Sprite, you will probably
have to do something like (again with the default image anchor
in the center)::

    rect = sprite.get_rect()
    rect.midbottom = (0, 100)
    sprite.position = rect.center

Returns a cocos.rect.Rect instance.

get_AABB(self)

 
Returns a local-coordinates Axis aligned Bounding Box

Returns a cocos.rect.Rect instance.

_set_rotation(self, a)

 
Overrides: pyglet.sprite.Sprite._set_rotation

_set_scale(self, s)

 
Overrides: pyglet.sprite.Sprite._set_scale

_set_x(self, x)

 
Overrides: pyglet.sprite.Sprite._set_x

_set_y(self, y)

 
Overrides: pyglet.sprite.Sprite._set_y

draw(self)

 

When the sprite is not into a batch it will be draw with this method.
If in a batch, this method is not called, and the draw is done by
the batch.

Overrides: pyglet.sprite.Sprite.draw

_update_position(self)

 
updates vertex list

Overrides: pyglet.sprite.Sprite._update_position