All About Scenes¶
Scenes are the terrain where sprites act. Each game has multiple scenes and may transition at any time.
-
class
ppb.
BaseScene
(*, set_up: Callable = None, pixel_ratio: numbers.Number = 64, **kwargs)[source]¶ -
add
(game_object: Hashable, tags: Iterable[T_co] = ()) → None[source]¶ Add a game_object to the scene.
game_object: Any GameObject object. The item to be added. tags: An iterable of Hashable objects. Values that can be used to
retrieve a group containing the game_object.- Examples:
scene.add(MyGameObject())
scene.add(MyGameObject(), tags=(“red”, “blue”)
-
get
(*, kind: Type[CT_co] = None, tag: Hashable = None, **kwargs) → Iterator[T_co][source]¶ Get an iterator of GameObjects by kind or tag.
- kind: Any type. Pass to get a subset of contained GameObjects with the
- given type.
- tag: Any Hashable object. Pass to get a subset of contained GameObjects
- with the given tag.
Pass both kind and tag to get objects that are both that type and that tag.
- Examples:
scene.get(type=MyGameObject)
scene.get(tag=”red”)
scene.get(type=MyGameObject, tag=”red”)
-