Working with Scenes
Amphora uses the concept of scenes to manage game levels. At its most basic, a scene is simply a C++ class implementing three methods: an init function, an update function, and a destroy function. When a scene is loaded, its init function is run once, then its update function is run once per frame, and finally its destroy function is run when it's unloaded.
Creating a Scene
Scenes are declared in the SceneList.txt file. An example SceneList.txt file could look as follows:
Each scene will have its own class which must take the following form:
Loading Scenes
A scene is loaded using Amphora::LoadScene(name). This will call the current scene's destroy function, free other allocated resources, then call the new scene's init function and begin running its update function.
For example, to load level 1, it'd be as simple as:
You can define a smooth fade between scenes using Amphora::SetSceneFadeParameters(duration, color), where duration is the time in milliseconds for the fade to take place, and color is an SDL_Color struct representing the color to fade to. So for example, to set a fade-to-black transition with a half second duration, you'd call:
During the fade, the current scene's update function will be paused, and the event system will be unavailable for use until the fade is complete, though already-registered events will continue to be processed.