GDevelop C++ Platform
Platform for developing native games based on OpenGL and SFML with GDevelop
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
RuntimeScene Class Reference

Represents a scene being played. More...

#include <RuntimeScene.h>

Inherits Scene.

Classes

struct  SceneChange
 

Public Member Functions

 RuntimeScene (sf::RenderWindow *renderWindow_, RuntimeGame *game_)
 
const RuntimeVariablesContainerGetVariables () const
 Provide access to the variables container.
 
RuntimeVariablesContainerGetVariables ()
 Provide access to the variables container.
 
std::shared_ptr< gd::ImageManager > GetImageManager () const
 Shortcut for game->GetImageManager() More...
 
const InputManagerGetInputManager () const
 Get the input manager used to handle mouse, keyboard and touches events.
 
InputManagerGetInputManager ()
 Get the input manager used to handle mouse, keyboard and touches events.
 
const TimeManagerGetTimeManager () const
 Get the time manager used to handle all time related values and timers.
 
TimeManagerGetTimeManager ()
 Get the time manager used to handle all time related values and timers.
 
RuntimeLayerGetRuntimeLayer (const gd::String &name)
 
const RuntimeLayerGetRuntimeLayer (const gd::String &name) const
 
const std::shared_ptr< BehaviorsRuntimeSharedData > & GetBehaviorSharedData (const gd::String &behaviorName) const
 Return the shared data for a behavior. More...
 
bool LoadFromScene (const gd::Layout &scene)
 Set up the RuntimeScene using a gd::Layout. More...
 
bool LoadFromSceneAndCustomInstances (const gd::Layout &scene, const gd::InitialInstancesContainer &instances)
 Set up the RuntimeScene using the specified instances and scene. More...
 
void CreateObjectsFrom (const gd::InitialInstancesContainer &container, float xOffset=0, float yOffset=0)
 
void ChangeRenderWindow (sf::RenderWindow *window)
 Change the window used for rendering the scene.
 
bool RenderWindowIsFullScreen ()
 Check if scene is rendered full screen.
 
void SetRenderWindowIsFullScreen (bool yes=true)
 Change full screen state. The render window is itself not changed so as to be displayed fullscreen or not.
 
bool RenderAndStep ()
 
void RenderWithoutStep ()
 Just render a frame, without applying logic or events on objects.
 
SceneChange GetRequestedChange ()
 
void RequestChange (SceneChange::Change change, gd::String sceneName="")
 
Code execution engine

Functions members giving access to the code execution engine.

std::shared_ptr< CodeExecutionEngineGetCodeExecutionEngine () const
 Give access to the execution engine of the scene. Each scene has its own unique execution engine.
 
void SetCodeExecutionEngine (std::shared_ptr< CodeExecutionEngine > codeExecutionEngine_)
 Give access to the execution engine of the scene. Each scene has its own unique execution engine.
 

Public Attributes

sf::RenderWindow * renderWindow
 Pointer to the render window used for display.
 
RuntimeGamegame
 Pointer to the game the scene is linked to.
 
BaseDebuggerdebugger
 Pointer to the debugger. Can be NULL.
 
ObjInstancesHolder objectsInstances
 Contains all of the objects on the scene.
 

Protected Member Functions

void ManageRenderTargetEvents ()
 Handle the events made on the scene's window.
 
bool OrderObjectsByZOrder (RuntimeObjNonOwningPtrList &objList)
 Order an object list according to object's Z coordinate.
 
void Render ()
 Render a frame in the window.
 
void ManageObjectsBeforeEvents ()
 To be called once during a step, to launch behaviors pre-events steps.
 
void ManageObjectsAfterEvents ()
 To be called once during a step, to remove objects marked as deleted in events, and to update objects position, forces and behaviors.
 
void SetupOpenGLProjection ()
 Set the OpenGL projection according to the window size and OpenGL scene options.
 

Protected Attributes

bool isFullScreen
 
InputManager inputManager
 
TimeManager timeManager
 
RuntimeVariablesContainer variables
 List of the scene variables.
 
std::vector< ExtensionBase * > extensionsToBeNotifiedOnObjectDeletion
 
BehaviorsRuntimeSharedDataHolder behaviorsSharedDatas
 Contains all behaviors shared datas.
 
std::vector< RuntimeLayerlayers
 The layers used at runtime to display the scene.
 
std::shared_ptr< CodeExecutionEnginecodeExecutionEngine
 
SceneChange requestedChange
 What should be done at the end of the frame.
 
sf::Clock clock
 The clock used to track time.
 

Static Protected Attributes

static RuntimeLayer badRuntimeLayer
 

Detailed Description

Represents a scene being played.

Contains game object instances and all runtime objects needed to play to a scene rendered in a SFML RenderWindow.

Member Function Documentation

◆ CreateObjectsFrom()

void RuntimeScene::CreateObjectsFrom ( const gd::InitialInstancesContainer &  container,
float  xOffset = 0,
float  yOffset = 0 
)

Create the objects from an gd::InitialInstancesContainer object.

Parameters
containerThe object containing the initial instances to be created
xOffsetThe offset on x axis to be applied to objects created
yOffsetThe offset on y axis to be applied to objects created

◆ GetBehaviorSharedData()

const std::shared_ptr<BehaviorsRuntimeSharedData>& RuntimeScene::GetBehaviorSharedData ( const gd::String &  behaviorName) const
inline

Return the shared data for a behavior.

Warning
Be careful, no check is made to ensure that the shared data exist.
Parameters
nameThe name of the behavior for which shared data must be fetched.

◆ GetImageManager()

std::shared_ptr< gd::ImageManager > RuntimeScene::GetImageManager ( ) const

Shortcut for game->GetImageManager()

Returns
The image manager of the game.

◆ GetRuntimeLayer() [1/2]

RuntimeLayer & RuntimeScene::GetRuntimeLayer ( const gd::String &  name)

Get the layer with specified name.

◆ GetRuntimeLayer() [2/2]

const RuntimeLayer & RuntimeScene::GetRuntimeLayer ( const gd::String &  name) const

Get the layer with specified name.

◆ LoadFromScene()

bool RuntimeScene::LoadFromScene ( const gd::Layout &  scene)

Set up the RuntimeScene using a gd::Layout.

Typically called automatically by the IDE or by the game executable.

Note
Similar to calling LoadFromSceneAndCustomInstances(scene, scene.GetInitialInstances());
See also
LoadFromSceneAndCustomInstances

◆ LoadFromSceneAndCustomInstances()

bool RuntimeScene::LoadFromSceneAndCustomInstances ( const gd::Layout &  scene,
const gd::InitialInstancesContainer &  instances 
)

Set up the RuntimeScene using the specified instances and scene.

Parameters
scenegd::Layout that should be loaded
instancesInitial instances to be put on the scene

◆ RenderAndStep()

bool RuntimeScene::RenderAndStep ( )

Render and play one frame.

Returns
true if a scene change was request, false otherwise.

Member Data Documentation

◆ badRuntimeLayer

RuntimeLayer RuntimeScene::badRuntimeLayer
staticprotected

Null object return by GetLayer when no appropriate layer could be found.

◆ extensionsToBeNotifiedOnObjectDeletion

std::vector<ExtensionBase*> RuntimeScene::extensionsToBeNotifiedOnObjectDeletion
protected

List, built during LoadFromScene, containing a list of extensions which must be notified when an object is deleted.

◆ isFullScreen

bool RuntimeScene::isFullScreen
protected

As sf::RenderWindow can't say if it is fullscreen or not


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