A Scene is the space in which GameObjects exist. More...
Detailed Description
A Scene is the space in which GameObjects exist.
The user is able to set create their own Scene objects which act as levels. The scene is a space that holds the active GameObjects and game entities.
The Scene base class only has two pure virtual functions to override:
Scene::Initialize() is called by the SceneManager when the scene starts up. The user should place code that creates, initializes, and registers GameObjects and game entities here. A very simple Scene::Initialize() may look like this:
UserScene.cpp:
This scene has two objects:
- A Tank
- A FirstPersonCam
The scene Initialize also:
- Applies a Terrain and SkyBox to the scene with Scene::SetTerrain() and Scene::SetSkyBox().
- Calls a factory singlton to create an EnemyTank object.
- Sets the scene camera to the user made IonCamera: FirstPersonCam.
- Registers collision pairs with Bullet, Tank, EnemyTank, and the Terrain. The Terrain and SkyBox are set based off a string key that was stored into the asset managers in IonEngine::LoadResources().
Scene::SceneEnd() is called by the SceneManager when the scene is about to be destroyed. The user should place code that destroys and deregisters GameObjects and game entities here. A very simple Scene::SceneEnd() may look like this:
UserScene.cpp:
- Note
- The pointers fpCam and obj_Tank are not being deleted in the Scene::SceneEnd() function. Genral C++ cleanup like 'delete' will stay within the scene's destructor.
The SceneManager holds functions for getting and setting the current Scene:
These can be used throughout the user's code to access the current scene or to switch scenes.
The user also has access to the IonEngine::InitializeEngine() function. Within this function the user can initialize singletons, set up window properties, and set the first scene. By default, the SceneManager will set the current scene to a completely empty scene called a NullScene. A simple IonEngine::InitializeEngine() function may look like this:
InitializeEngine.cpp:
Within the IonEngine::InitializeEngine() the user may call other Engine class functions for setting window properties. Some of these include:
- IonEngine::setVsync() - Enables/Disables an FPS cap to the monitor's refresh rate
- IonEngine::EnableDebugTitle() - Enables/Disables setting the window to have debug information such as total time, FPS, and frame time in ms.
- IonEngine::setDXReport() - Enables/Disables a DirectX report of live device objects at the end of the application.
Classes | |
class | Scene |
The space in which gameobjects exist. More... | |
class | SceneManager |
System manager for storage and access to the current scene. More... | |
Functions | |
void | IonEngine::InitializeEngine () |
Public engine function for initialization of the engine. More... | |
void | IonEngine::EngineEnd () |
Public engine function that is called when shitting down. More... | |
Function Documentation
|
private |
Public engine function that is called when shitting down.
Within the EngineEnd() function the user can preform cleanup on objects that normally aren't cleaned up elsewhere (like singletons).
|
private |
Public engine function for initialization of the engine.
Within the InitializeEngine() function the user can set up start up operations such as setting window dimensions, creation of the first scene, initialization of singletons, etc...