Module cocos.director

cocos.director.director is the singleton that creates and handles the main Window and manages the logic behind the Scenes.

Initializing

The first thing to do, is to initialize the director:

from cocos.director import director
director.init( parameters )

This will initialize the director, and will create a display area (a 640x480 window by default). The parameters that are supported by director.init() are the same parameters that are supported by pyglet.window.Window(), plus a few cocos exclusive ones. They are all named parameters (kwargs). See Director.init() for details.

Example:

director.init( width=800, height=600, caption="Hello World", fullscreen=True )

Running a Scene

Once you have initialized the director, you can run your first Scene:

director.run( Scene( MyLayer() ) )

This will run a scene that has only 1 layer: MyLayer(). You can run a scene that has multiple layers. For more information about Layers and Scenes refer to the Layers and Scene documentation.

Once a scene is running you can do the following actions:

Other functions you can use are:

The director also has some useful attributes:

Classes

  DefaultHandler
  Director
Class that creates and handle the main Window and manages how and when to execute the Scenes

Variables

  director = Director()