# cocos.layer.base_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 `Layer`

  Bases: `cocos.cocosnode.CocosNode`, `cocos.scene.EventHandlerMixin`

  a CocosNode that automatically handles listening to director.window events

  `on_enter`()
  `on_exit`()
  `push_all_handlers`()

    registers itself to receive director.window events and propagates the call to childs that are layers. class member is_event_handler must be True for this to work

  `remove_all_handlers`()

    de-registers itself to receive director.window events and propagates the call to childs that are layers. class member is_event_handler must be True for this to work

  `is_event_handler` = False

    if true, the event handlers of this layer will be registered. defaults to false.

class `MultiplexLayer`(*layers)

  Bases: `cocos.layer.base_layers.Layer`

  A Composite layer that only enables one layer at the time.

  This is useful, for example, when you have 3 or 4 menus, but you want to show one at the time

  `switch_to`(layer_number)

    Switches to another Layer that belongs to the Multiplexor.

    Parameters: | layer_number : Integer MUST be a number between 0 and the quantities of layers - 1. The running layer will receive an “on_exit()” call, and the new layer will receive an “on_enter()” call.