Scenes

Every scar app is organized in scenes. A scene is a container for spaces. It should contain everything that has to exist in one single game scene. For instance, there could be a splashscreen scene, a main menu scene and a gameplay scene.

Scenes can be created with spaces as parameters or without without them. << and pop can then be used afterwards to add or remove them, [] or []? or spaces to get specific spaces. Calling update and render are handled by the App containing the scene.

The scenes are managed by the App scene stack. You can access it via App#<<, App#pop, or the scene_stack getter. App#scene returns the topmost scene for convenient access. Only the scene on top of the scene stack gets updated and rendered.

Because of the stack structure, scenes can be inserted one after another and afterwards pop'ed off the stack. This can be used to e. g. show a main menu scene, then start the gameplay scene and then popping it to see the menu again. Scenes on the stack are not deleted until they are popped.

An example can be found in the next section.

Last updated