# Class cocos.sprite.Sprite

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

A CocosNode that displays a rectangular image.

Example:

    sprite = Sprite('grossini.png')

## Nested Classes

| supported_classes A CocosNode that displays a rectangular image.

## Events

Inherited from `pyglet.sprite.Sprite`: `on_animation_end`

## Methods

| __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
| contains(self, x, y) Test whether this (untransformed) Sprite contains the pixel coordinates given.
| draw(self) When the sprite is not into a batch it will be draw with this method.
| __contains__(self, child) (Inherited from cocos.cocosnode.CocosNode)
CocosNode instance | add(self, child, z=0, name=None) Adds a child to the container (Inherited from cocos.batch.BatchableNode)
| are_actions_running(self) Determine whether any actions are running. (Inherited from cocos.cocosnode.CocosNode)
Action instance | do(self, action, target=None) Executes an action. (Inherited from cocos.cocosnode.CocosNode)
CocosNode | get(self, name) Gets a child from the container given its name (Inherited from cocos.cocosnode.CocosNode)
CocosNode or None | get_ancestor(self, klass) Walks the nodes tree upwards until it finds a node of the class `klass` or returns None (Inherited from cocos.cocosnode.CocosNode)
list of CocosNode | get_children(self) Return a list with the node's childs (Inherited from cocos.cocosnode.CocosNode)
euclid.Matrix3 | get_local_inverse(self) returns an euclid.Matrix3 with the local inverse transformation matrix (Inherited from cocos.cocosnode.CocosNode)
euclid.Matrix3 | get_local_transform(self) returns an euclid.Matrix3 with the local transformation matrix (Inherited from cocos.cocosnode.CocosNode)
euclid.Matrix3 | get_world_inverse(self) returns an euclid.Matrix3 with the world inverse transformation matrix (Inherited from cocos.cocosnode.CocosNode)
euclid.Matrix3 | get_world_transform(self) returns an euclid.Matrix3 with the world transformation matrix (Inherited from cocos.cocosnode.CocosNode)
| kill(self) Remove this object from its parent, and thus most likely from everything. (Inherited from cocos.cocosnode.CocosNode)
| on_enter(self) Called every time just before the node enters the stage. (Inherited from cocos.cocosnode.CocosNode)
| on_exit(self) Called every time just before the node leaves the stage (Inherited from cocos.cocosnode.CocosNode)
| pause(self) Suspends the execution of actions. (Inherited from cocos.cocosnode.CocosNode)
| pause_scheduler(self) Time will stop passing for this node: scheduled callbacks will not be called, worker actions will not be called (Inherited from cocos.cocosnode.CocosNode)
euclid.Vector2 | point_to_local(self, p) returns an euclid.Vector2 converted to local space (Inherited from cocos.cocosnode.CocosNode)
euclid.Vector2 | point_to_world(self, p) returns an euclid.Vector2 converted to world space (Inherited from cocos.cocosnode.CocosNode)
| remove(self, child) Removes a child from the container given its name or object (Inherited from cocos.batch.BatchableNode)
| remove_action(self, action) Removes an action from the node actions container, potentially calling action.stop() (Inherited from cocos.cocosnode.CocosNode)
| resume(self) Resumes the execution of actions. (Inherited from cocos.cocosnode.CocosNode)
| resume_scheduler(self) Time will continue/start passing for this node and callbacks will be called, worker actions will be called (Inherited from cocos.cocosnode.CocosNode)
| schedule(self, callback, *args, **kwargs) Schedule a function to be called every frame. (Inherited from cocos.cocosnode.CocosNode)
| schedule_interval(self, callback, interval, *args, **kwargs) Schedule a function to be called every `interval` seconds. (Inherited from cocos.cocosnode.CocosNode)
| set_batch(self, batch, groups=None, z=0) (Inherited from cocos.batch.BatchableNode)
| stop(self) Removes all actions from the running action list (Inherited from cocos.cocosnode.CocosNode)
| transform(self) Apply ModelView transformations (Inherited from cocos.cocosnode.CocosNode)
| unschedule(self, callback) Remove a function from the schedule. (Inherited from cocos.cocosnode.CocosNode)
| visit(self) This function visits it's children in a recursive way. (Inherited from cocos.cocosnode.CocosNode)
list | walk(self, callback, collect=None) Executes callback on all the subtree starting at self. (Inherited from cocos.cocosnode.CocosNode)
Inherited from `pyglet.sprite.Sprite`: `__del__`, `delete`, `set_position` Inherited from `pyglet.event.EventDispatcher`: `dispatch_event`, `event`, `pop_handlers`, `push_handlers`, `register_event_type`, `remove_handler`, `remove_handlers`, `set_handler`, `set_handlers`

## Properties

| image_anchor_x
| image_anchor_y
| image_anchor
(int,int) | anchor Anchor point of the object. (Inherited from cocos.cocosnode.CocosNode)
(int,int) | anchor_x Anchor x value for transformations and adding children (Inherited from cocos.cocosnode.CocosNode)
(int,int) | anchor_y Anchor y value for transformations and adding children (Inherited from cocos.cocosnode.CocosNode)
object | parent The parent of this object. (Inherited from cocos.cocosnode.CocosNode)
(int,int) | transform_anchor Transformation anchor point. (Inherited from cocos.cocosnode.CocosNode)
| x The x coordinate of the object (Inherited from cocos.cocosnode.CocosNode)
| y The y coordinate of the object (Inherited from cocos.cocosnode.CocosNode)
Inherited from `pyglet.sprite.Sprite`: `batch`, `group`, `height`, `image`, `width`

## Instance Variables

| 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
| actions list of Action objects that are running (Inherited from cocos.cocosnode.CocosNode)
| camera eye, center and up vector for the Camera. (Inherited from cocos.cocosnode.CocosNode)
| children list of children. (Inherited from cocos.cocosnode.CocosNode)
| children_names dictionary that maps children names with children references (Inherited from cocos.cocosnode.CocosNode)
| grid the grid object for the grid actions. (Inherited from cocos.cocosnode.CocosNode)
| is_running whether of not the object is running (Inherited from cocos.cocosnode.CocosNode)
| scheduled_calls list of scheduled callbacks (Inherited from cocos.cocosnode.CocosNode)
| scheduled_interval_calls list of scheduled interval callbacks (Inherited from cocos.cocosnode.CocosNode)
| skip_frame whether or not the next frame will be skipped (Inherited from cocos.cocosnode.CocosNode)
| to_remove list of Action objects to be removed (Inherited from cocos.cocosnode.CocosNode)
| transform_anchor_x offset from (x,0) from where rotation and scale will be applied. (Inherited from cocos.cocosnode.CocosNode)
| transform_anchor_y offset from (0,y) from where rotation and scale will be applied. (Inherited from cocos.cocosnode.CocosNode)
| visible whether of not the object is visible. (Inherited from cocos.cocosnode.CocosNode)

## Class Variables

Inherited from `pyglet.sprite.Sprite`: `event_types`

## 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).
Overrides:
  cocosnode.CocosNode.__init__

### draw

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:
  cocosnode.CocosNode.draw

## Property Details

### image_anchor_x

### image_anchor_y

### image_anchor

## Instance Variable Details

### rotation

rotation degrees of the sprite. Default: 0 degrees