A Scene is the space in which GameObjects exist. More...

Collaboration diagram for Scene:

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:

void UserScene::Initialize()
{
SetTerrain("Terrain_Grass");
SetSkyBox("SkyBox_Cloudy");
obj_Tank = new Tank();
EnemyFactory::CreateEnemyTank(Vect(750, 1, 500), obj_Tank->GetTankPos());
fpCam = new FirstPersonCam(obj_Tank->GetCamPos(), obj_Tank->GetCamRot());
this->SetCamera(fpCam);
SetCollisionPair<Tank, Bullet>();
SetCollisionPair<EnemyTank, Bullet>();
SetCollisionSelf<Bullet>();
SetCollisionTerrain<Bullet>();
}

This scene has two objects:

  • A Tank
  • A FirstPersonCam

The scene Initialize also:

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:

void UserScene::SceneEnd()
{
//clean up all factories
BulletFactory::Delete();
EnemyFactory::Delete();
}
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:

{
// Use this area, for one time non-graphic creation
//Creates and Sets first scene
SceneManager::SceneChange(new UserScene());
// IonEngine Window Device setup
IonEngine::SetWindowName("Ion Engine");
IonEngine::SetBackgroundColor(Color::AliceBlue);
IonEngine::setVsync(false);
IonEngine::setDXReport(true);
}

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

void IonEngine::EngineEnd ( )
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).

void IonEngine::InitializeEngine ( )
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...