Scenes
Organize a program into scenes with lifecycle and input callbacks.
- class pydraw.scene.Scene
Bases:
objectAn abstraction of the Screen, designed to store the Screen in a certain state while retaining registered input handlers and the positions and attributes of objects registered to it.
You can use Scenes to create multi-screen games or to manage different levels easily. It works exactly like a screen but will not render anything until it is “applied” to a Screen via Screen.scene(some_scene)
- activate(screen: Screen) None
Activates the Scene with a Screen (called internally)
- Parameters:
screen – the Screen to display the Scene on
- Returns:
None
- keydown(key: Key) None
Key event called when a key is pressed
- Parameters:
key – the Key that was pressed
- Returns:
None
- keyup(key: Key) None
Key event called when a key is released
- Parameters:
key – the Key that was released
- Returns:
None
- mousedown(location: Location, button: int) None
Mouse event, called when a mouse button is pressed down.
- Parameters:
location – the location that was clicked
button – the button pressed (0-2)
- Returns:
None
- mousedrag(location: Location, button: int) None
Mouse event, called when the mouse moves after a mousedown event (without a mouseup event)
- Parameters:
location – the Location the mouse has moved to
button – the button being held (0-2)
- Returns:
None
- mousemove(location: Location) None
Mouse event called when the mouse moves over the Screen
- Parameters:
location – the Location the mouse moved to
- Returns:
None
- mouseup(location: Location, button: int) None
Mouse event, called when a mouse button is released.
- Parameters:
location – the location that was clicked
button – the button released (0-2)
- Returns:
None
- run() None
Run the scene (the loop should go here)
- Returns:
None
- screen()
Retrieve the screen that the scene is tied to
- Returns:
a Screen
- start() None
Run as the initializer for the scene
- Returns:
None