cocos.scene module

Scene class.

class Scene(*children)

Bases: cocos.cocosnode.CocosNode

Creates a Scene with layers and / or scenes.

Control the dispatching of events to its layers; and background music playback.
Parameters:children (list[Layer or Scene]) – Layers or Scenes that will be part of the scene. They are automatically assigned a z-level from 0 to num_children.

Ends the current scene.

This is accomplished by calling Director.pop(). Also sets director.return_value to value.

Parameters:value (anything) – The return value. It can be anything. A type or an instance.

This prepares a streamed music file to be played in this scene.

Music will be stopped after calling this (even if it was playing before).

Parameters:filename (str) – Filename of music to load. Depending on installed libraries, supported formats may be WAV, MP3, OGG, MOD. You can also use None to unset music.

Called every time the Scene enters the stage.


Called every time the Scene exits the stage.


Enable music playback for this scene. Nothing happens if music was already playing.

Note that if you call this method on an inactive scene, the music will start playing back only if/when the scene gets activated.


Stops music playback for this scene.