Class cocos.layer.util_layers.ColorLayer

             object --+        
                      |        
    cocosnode.CocosNode --+    
                          |    
             object --+   |    
                      |   |    
scene.EventHandlerMixin --+    
                          |    
          base_layers.Layer --+
                              |
                             ColorLayer

Creates a layer of a certain color. The color shall be specified in the format (r,g,b,a).

For example, to create green layer:

l = ColorLayer(0, 255, 0, 0 )

The size and position can be changed, for example:

l = ColorLayer( 0, 255,0,0, width=200, height=400)
l.position = (50,50)

Methods

  __init__(self, r, g, b, a, width=None, height=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
  on_enter(self)
Called every time just before the node enters the stage.
  on_exit(self)
Called every time just before the node leaves the stage
  draw(self)
This is the function you will have to override if you want your subclassed to draw something on screen.
Inherited from base_layers.Layer: push_all_handlers, remove_all_handlers Inherited from cocosnode.CocosNode: __contains__, add, are_actions_running, do, get, get_ancestor, get_children, pause, pause_scheduler, remove, remove_action, resume, resume_scheduler, schedule, schedule_interval, stop, transform, unschedule, visit, walk Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Instance Variables

Inherited from cocosnode.CocosNode: actions, camera, children, children_anchor_x, children_anchor_y, children_names, grid, is_running, rotation, scale, scheduled_calls, scheduled_interval_calls, skip_frame, to_remove, transform_anchor_x, transform_anchor_y, visible, x, y

Class Variables

  opacity = property(lambda self: self._opacity, _set_opacity, d...
  color = property(lambda self: self._rgb, _set_color, doc= '''B...
Inherited from base_layers.Layer: is_event_handler Inherited from cocosnode.CocosNode: anchor, anchor_x, anchor_y, children_anchor, parent, position, transform_anchor

Method Details

__init__

(Constructor) __init__(self, r, g, b, a, width=None, height=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides:
base_layers.Layer.__init__

on_enter

on_enter(self)
Called every time just before the node enters the stage.
Overrides:
base_layers.Layer.on_enter

on_exit

on_exit(self)
Called every time just before the node leaves the stage
Overrides:
base_layers.Layer.on_exit

draw

draw(self)

This is the function you will have to override if you want your subclassed to draw something on screen.

You must respect the position, scale, rotation and anchor attributes. If you want OpenGL to do the scaling for you, you can:

def draw(self):
    glPushMatrix()
    self.transform()
    # ... draw ..
    glPopMatrix()
Overrides:
cocosnode.CocosNode.draw

Class Variable Details

opacity

Value:
property(lambda self: self._opacity, _set_opacity, doc= '''Blend opaci\
ty.

    This property sets the alpha component of the colour of the layer'\
s
    vertices.  This allows the layer to be drawn with fractional opaci\
ty,
    blending with the background.
...

color

Value:
property(lambda self: self._rgb, _set_color, doc= '''Blend color.

    This property sets the color of the layer's vertices. This allows \
the
    layer to be drawn with a color tint.
    
    The color is specified as an RGB tuple of integers ``(red, green, \
blue)``.
...