cocos.layer.util_layers module — cocos v0.6.10 documentation

# cocos.layer.util_layers module

Special purpose layers

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

  Bases: `cocos.layer.base_layers.Layer`

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

  For example, to create a green layer:

      layer = ColorLayer(0, 255, 0, 0)

  The size and position can be changed, for example:

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

  Parameters:

    - r (int) – red component

    - g (int) – green component

    - b (int) – blue component

    - a (int) – alpha component

    - width (int) – width of the color layer [Optional]

    - height (int) – height of the color layer [Optional]

  `draw`()

    Draws itself.

  `on_enter`()

    Called every time just before the node enters the stage.

  `on_exit`()

    Called every time just before the node exits the stage.

  property `color`

    Blend color.

    This property sets the color of the layer’s vertices. This allows the layer to be drawn with a color tint.

    Parameters:

      color (tuple[int, int, int]) – 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).

  property `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 ColorLayer appear translucent.

    Parameters:

      opacity (int) – the opacity ranging from 0 (transparent) to 255 (opaque).