Gorgon Game Engine
Scene Class Referenceabstract

This class represents a scene in the game like menu screen in game, post game, pause or different game modes. More...

Inheritance diagram for Scene:
[legend]

Public Member Functions

 Scene (SceneID id=NoSceneID, bool mouseinput=true)
 Empty constructor. More...
 
 Scene (SceneManager &parent, SceneID id=NoSceneID, bool mouseinput=true)
 Sets the parent layer so that the scene can be activated. More...
 
virtual void Activate () override
 Activates the current scene. More...
 
SceneID GetID () const
 Returns the ID of the current scene. More...
 
virtual void KeyEvent (Gorgon::Input::Key, float)
 Called when the scene receives a key. More...
 
virtual bool RequiresKeyInput () const =0
 Whether this scene requires keyboard input. More...
 
- Public Member Functions inherited from Governor
virtual ~Governor ()
 Destroys this governor. If it is the active governor, default governor will be activated. More...
 
virtual void Animate () const
 Animates the animations within this governor. More...
 

Public Attributes

Gorgon::Event< SceneActivatedEvent
 Fires whenever activation of this layer is completed. More...
 
Gorgon::Event< SceneDeactivatedEvent
 Fires whenever deactivation of this layer is completed. More...
 

Protected Member Functions

virtual void activate ()
 Called after very activation. More...
 
virtual void deactivate ()
 Called before deactivation. More...
 
virtual void doframe (unsigned int delta)=0
 Scene should perform its frame based operations in this function. More...
 
virtual void first_activation ()
 Called only for the first time this scene is activated. More...
 
virtual void render ()=0
 This is called after doframe to perform rendering operation. More...
 
void setlayerbounds (const Geometry::Bounds &bounds)
 Changes the boundaries of the main layer. More...
 

Protected Attributes

Gorgon::Graphics::Layer graphics
 Graphics layer that can be drawn on. More...
 
SceneID id
 ID of the current scene. More...
 
Gorgon::Input::Layer mouse
 Mouse layer that can be used to receive mouse events. More...
 
SceneManagerparent
 The parent window for the scene. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Governor
static GovernorActive ()
 Returns the current governor. More...
 
static GovernorDefault ()
 Returns the default governor. More...
 

Detailed Description

This class represents a scene in the game like menu screen in game, post game, pause or different game modes.

Scenes can be swapped on the fly and some scenes can be linked to others. Scene class is abstract, it must be derived by other classes in order to work.

Constructor & Destructor Documentation

◆ Scene() [1/2]

Scene ( SceneID  id = NoSceneID,
bool  mouseinput = true 
)
explicit

Empty constructor.

After this constructor, the scene cannot be activated.

◆ Scene() [2/2]

Scene ( SceneManager parent,
SceneID  id = NoSceneID,
bool  mouseinput = true 
)
explicit

Sets the parent layer so that the scene can be activated.

Member Function Documentation

◆ activate()

virtual void activate ( )
protectedvirtual

Called after very activation.

first_activation will be called before activate.

◆ Activate()

void Activate ( )
overridevirtual

Activates the current scene.

Reimplemented from Governor.

References Scene::parent, and SceneManager::SwitchScene().

◆ deactivate()

virtual void deactivate ( )
protectedvirtual

Called before deactivation.

◆ doframe()

virtual void doframe ( unsigned int  delta)
protectedpure virtual

Scene should perform its frame based operations in this function.

◆ first_activation()

virtual void first_activation ( )
protectedvirtual

Called only for the first time this scene is activated.

Allocate your resources here.

◆ GetID()

SceneID GetID ( ) const

Returns the ID of the current scene.

References Scene::id.

◆ KeyEvent()

virtual void KeyEvent ( Gorgon::Input::Key  ,
float   
)
virtual

Called when the scene receives a key.

◆ render()

virtual void render ( )
protectedpure virtual

This is called after doframe to perform rendering operation.

It is possible to receive render without receiving doframe, thus they should not be co-dependent.

◆ RequiresKeyInput()

virtual bool RequiresKeyInput ( ) const
pure virtual

Whether this scene requires keyboard input.

◆ setlayerbounds()

void setlayerbounds ( const Geometry::Bounds bounds)
protected

Changes the boundaries of the main layer.

References Layer::SetBounds().

Member Data Documentation

◆ ActivatedEvent

Gorgon::Event<Scene> ActivatedEvent

Fires whenever activation of this layer is completed.

Will not be fired if the layer is already active and Activate function is called.

◆ DeactivatedEvent

Gorgon::Event<Scene> DeactivatedEvent

Fires whenever deactivation of this layer is completed.

Will not be fired if the layer is already inactive and Deactivate function is called.

◆ graphics

Gorgon::Graphics::Layer graphics
protected

Graphics layer that can be drawn on.

◆ id

SceneID id
protected

ID of the current scene.

◆ mouse

Gorgon::Input::Layer mouse
protected

Mouse layer that can be used to receive mouse events.

If the mouseinput parameter of the constructor is set to true, this layer will be attached, otherwise it will not be functional.

◆ parent

SceneManager* parent
protected

The parent window for the scene.

Unless you are explicitly requesting a parent, this member could be nullptr.


The documentation for this class was generated from the following file: