Gamedev Framework (gf)  0.17.0
A C++14 framework for 2D games
Public Member Functions | List of all members
gf::SceneManager Class Reference

A scene manager. More...

#include <gf/SceneManager.h>

Public Member Functions

 SceneManager (StringRef title, Vector2i size, Flags< WindowHints > hints=All)
 Constructor. More...
 
void run (const RenderStates &states=RenderStates())
 Run the scene manager until completion. More...
 
void pushScene (Scene &scene)
 Add a scene on top of the stack. More...
 
void pushScenes (ArrayRef< Ref< Scene >> scenes)
 Add multiple scenes on top of the stack. More...
 
void popScene ()
 Remove the top scene from the non-empty stack. More...
 
void popAllScenes ()
 Remove all the scenes from the non-empty stack. More...
 
void replaceScene (Scene &scene)
 Replace the top scene with a new scene. More...
 
void replaceScene (ArrayRef< Ref< Scene >> scenes)
 Replace the top scene with many scenes. More...
 
void replaceAllScenes (Scene &scene)
 Replace all the scenes with a new scene. More...
 
void replaceAllScenes (ArrayRef< Ref< Scene >> scenes)
 Replace all the scenes with many scenes. More...
 
void replaceScene (Scene &scene, SegueEffect &effect, Time duration, Easing easing=Ease::linear)
 Replace the top scene with a new scene and a transition. More...
 
void replaceScene (ArrayRef< Ref< Scene >> scenes, SegueEffect &effect, Time duration, Easing easing=Ease::linear)
 Replace the top scene with many scenes and a transition. More...
 
void replaceAllScenes (Scene &scene, SegueEffect &effect, Time duration, Easing easing=Ease::linear)
 Replace all the scenes with a new scene and a transition. More...
 
void replaceAllScenes (ArrayRef< Ref< Scene >> scenes, SegueEffect &effect, Time duration, Easing easing=Ease::linear)
 Replace all the scenes with many scenes and a transition. More...
 
WindowgetWindow ()
 Get the window associated to the scene. More...
 
RenderTargetgetRenderer ()
 Get the renderer associated to the scene. More...
 
Vector2f computeWindowToGameCoordinates (Vector2i coords, const View &view) const
 Get the game coordinates from the window coordinates. More...
 
Vector2i computeGameToWindowCoordinates (Vector2f coords, const View &view) const
 Get the window coordinates from the game coordinates. More...
 

Detailed Description

A scene manager.

A scene manager handles several scenes, organised into a stack. It has a window and a renderer and use them to handle the scenes.

The top of the stack is the active scene. The manager runs the active scene while the stack is not empty. All the scene in the stack receive inputs, are updated and are rendered, beginning from the base of the stack until the top.

See also
gf::Scene

Constructor & Destructor Documentation

◆ SceneManager()

gf::SceneManager::SceneManager ( StringRef  title,
Vector2i  size,
Flags< WindowHints hints = All 
)

Constructor.

Parameters
titleThe title of the window
sizeThe initial size of the window
hintsSome hints for the creation of the window

Member Function Documentation

◆ computeGameToWindowCoordinates()

Vector2i gf::SceneManager::computeGameToWindowCoordinates ( Vector2f  coords,
const View view 
) const

Get the window coordinates from the game coordinates.

See also
RenderTarget::mapCoordsToPixel()

◆ computeWindowToGameCoordinates()

Vector2f gf::SceneManager::computeWindowToGameCoordinates ( Vector2i  coords,
const View view 
) const

Get the game coordinates from the window coordinates.

See also
RenderTarget::mapPixelToCoords()

◆ getRenderer()

RenderTarget& gf::SceneManager::getRenderer ( )
inline

Get the renderer associated to the scene.

◆ getWindow()

Window& gf::SceneManager::getWindow ( )
inline

Get the window associated to the scene.

◆ popAllScenes()

void gf::SceneManager::popAllScenes ( )

Remove all the scenes from the non-empty stack.

◆ popScene()

void gf::SceneManager::popScene ( )

Remove the top scene from the non-empty stack.

◆ pushScene()

void gf::SceneManager::pushScene ( Scene scene)

Add a scene on top of the stack.

Parameters
sceneThe scene to add

◆ pushScenes()

void gf::SceneManager::pushScenes ( ArrayRef< Ref< Scene >>  scenes)

Add multiple scenes on top of the stack.

Parameters
scenesThe scenes to add

◆ replaceAllScenes() [1/4]

void gf::SceneManager::replaceAllScenes ( Scene scene)
inline

Replace all the scenes with a new scene.

It is equivalent to popping all the scenes and pushing the new scene.

Parameters
sceneThe scene to add

◆ replaceAllScenes() [2/4]

void gf::SceneManager::replaceAllScenes ( ArrayRef< Ref< Scene >>  scenes)
inline

Replace all the scenes with many scenes.

It is equivalent to popping all the scenes and pushing the new scenes.

Parameters
scenesThe scenes to add

◆ replaceAllScenes() [3/4]

void gf::SceneManager::replaceAllScenes ( Scene scene,
SegueEffect effect,
Time  duration,
Easing  easing = Ease::linear 
)

Replace all the scenes with a new scene and a transition.

Parameters
sceneThe scene to add
effectThe effect during the transition
durationThe duration of the transition
easingThe easing of the transition

◆ replaceAllScenes() [4/4]

void gf::SceneManager::replaceAllScenes ( ArrayRef< Ref< Scene >>  scenes,
SegueEffect effect,
Time  duration,
Easing  easing = Ease::linear 
)

Replace all the scenes with many scenes and a transition.

Parameters
scenesThe scenes to add
effectThe effect during the transition
durationThe duration of the transition
easingThe easing of the transition

◆ replaceScene() [1/4]

void gf::SceneManager::replaceScene ( Scene scene)
inline

Replace the top scene with a new scene.

It is equivalent to popping the current top scene and pushing the new scene.

Parameters
sceneThe scene to add

◆ replaceScene() [2/4]

void gf::SceneManager::replaceScene ( ArrayRef< Ref< Scene >>  scenes)
inline

Replace the top scene with many scenes.

It is equivalent to popping the current top scene and pushing the new scenes.

Parameters
scenesThe scenes to add

◆ replaceScene() [3/4]

void gf::SceneManager::replaceScene ( Scene scene,
SegueEffect effect,
Time  duration,
Easing  easing = Ease::linear 
)

Replace the top scene with a new scene and a transition.

Parameters
sceneThe scene to add
effectThe effect during the transition
durationThe duration of the transition
easingThe easing of the transition

◆ replaceScene() [4/4]

void gf::SceneManager::replaceScene ( ArrayRef< Ref< Scene >>  scenes,
SegueEffect effect,
Time  duration,
Easing  easing = Ease::linear 
)

Replace the top scene with many scenes and a transition.

Parameters
scenesThe scenes to add
effectThe effect during the transition
durationThe duration of the transition
easingThe easing of the transition

◆ run()

void gf::SceneManager::run ( const RenderStates states = RenderStates())

Run the scene manager until completion.

Parameters
statesThe render states to use for drawing