Scene management
Overview
EiffelMedia has the notion of a scene. This denotes an interactive scene which displays some content and allows user input. A scene can be an intro screen, a menu, a game screen, a loading screen, etc.
Scene types
The base type of any scene - EM_SCENE - is deferred and thus can not be used directly. There are various scene types alredy implemented and chances are you want to use one of them:
- EM_DRAWABLE_SCENE: A scene which has an EM_DRAWABLE_CONTAINER and can be used to display drawables.
-
EM_COMPONENT_SCENE: A component scene is used in conjunction with
components and widgets.
Note: If you want to use OpenGL and widgets you will need a component scene.
-
EM_WIDGET_SCENE:The widget scene is used to
display widgets. Although you can also use a component scene to
display widgets the widget scene has the advantage of beeing itself a widget and thus has the same properties
like widgets. In particular the widget scene can have a background and a border.
Note: When using a widget scene you can use widgets only, especially no 3D components.
- EM_GL_SCENE: A scene which uses OpenGL to draw the content. When using this scene type you cannot use normal drawing commands on the screen. Only OpenGL drawing is allowed.
Components, widgets and windows will only work with component and widget scenes.
Scene change
To change the running scene, call set_next_scene and start_next_scene on the current scene.
Component and widget scene
There are two ways to use eiter a component scene or a widget scene:
-
Create a subclass of the desired scene type and add components or widgets using
add_component or
add_widget.
This can either be done in the creator of the class or when redefining
initialize_scene.
Note: When subclassing an EM_COMPONENT_SCENE make sure to call make_component_scene at creation.Note: When subclassing an EM_WIDGET_SCENE make sure to call make_widget_scene at creation.
- Create an object of the scene type and add components or widgets calling add_component or add_widget on the object.