### Navigation

- index
- modules |
- next |
- previous |
- cocos »
- cocos package »
- cocos.layer package »

# cocos.layer.util_layers module

Layer class and subclasses

A Layer has as size the whole drawable area (window or screen), and knows how to draw itself. It can be semi transparent (having holes and/or partial transparency in some/all places), allowing to see other layers behind it. Layers are the ones defining appearance and behavior, so most of your programming time will be spent coding Layer subclasses that do what you need. The layer is where you define event handlers. Events are propagated to layers (from front to back) until some layer catches the event and accepts it.

class `ColorLayer`(r, g, b, a, width=None, height=None)

  Bases: `cocos.layer.base_layers.Layer`

  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)

  `draw`()
  `on_enter`()
  `on_exit`()
  `color`

    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)`. Each color component must be in the range 0 (dark) to 255 (saturated).

    Type: | (int, int, int)

  `opacity`

    Blend opacity.

    This property sets the alpha component of the colour of the layer’s vertices. This allows the layer to be drawn with fractional opacity, blending with the background.

    An opacity of 255 (the default) has no effect. An opacity of 128 will make the sprite appear translucent.

    Type: | int

### Navigation

- index
- modules |
- next |
- previous |
- cocos »
- cocos package »
- cocos.layer package »