RuntimeGame

RuntimeGame

Represents a game being played.

Constructor

new RuntimeGame(data, options)

Parameters:
Name Type Description
data

The object (usually stored in data.json) containing the full project data

options
Source:

Methods

enableMetrics()

Set if the session should be registered.

Source:

getAdaptGameResolutionAtRuntime()

Returns if the game resolution should be automatically adapted when the game window or screen size change. This will only be the case if the game resolution resize mode is configured to adapt the width or the height of the game.

Returns:
Type Description

true if the game resolution is automatically changed according to the window/screen size.

Source:

getAdditionalOptions()

Return the additional options passed to the RuntimeGame when created.

Returns:
Type Description

The additional options, if any.

Source:

getBitmapFontManager()

Get the gdjs.BitmapFontManager of the RuntimeGame.

Returns:
Type Description

The bitmap font manager.

Source:

getEffectsManager()

Get the effects manager of the game, which allows to manage effects on runtime objects or runtime layers.

Returns:
Type Description

The effects manager for the game

Source:

getExtensionProperty(extensionName, propertyName)

Gets an extension property from the project data.

Parameters:
Name Type Description
extensionName

The extension name.

propertyName

The property name.

Returns:
Type Description

The property value.

Source:

getExternalLayoutData(name)

Get the data associated to an external layout.

Parameters:
Name Type Description
name

The name of the external layout.

Returns:
Type Description

The data associated to the external layout or null if not found.

Source:

getFontManager()

Get the gdjs.FontManager of the RuntimeGame.

Returns:
Type Description

The font manager.

Source:

getGameData()

Get the object containing the game data

Returns:
Type Description

The object associated to the game.

Source:

getGameResolutionHeight()

Get the game resolution (the size at which the game is played and rendered) height.

Returns:
Type Description

The game resolution height, in pixels.

Source:

getGameResolutionResizeMode()

Returns if the width or the height of the game resolution should be changed to fit the game window - or if the game resolution should not be updated automatically (empty string).

Returns:
Type Description

Either "" (don't change game resolution), "adaptWidth" or "adaptHeight".

Source:

getGameResolutionWidth()

Get the game resolution (the size at which the game is played and rendered) width.

Returns:
Type Description

The game resolution width, in pixels.

Source:

getImageManager()

Get the gdjs.ImageManager of the RuntimeGame.

Returns:
Type Description

The image manager.

Source:

getInitialObjectsData()

Get the data representing all the global objects of the game.

Returns:
Type Description

The data associated to the global objects.

Source:

getInputManager()

Get the input manager of the game, storing mouse, keyboard and touches states.

Returns:
Type Description

The input manager owned by the game

Source:

getJsonManager()

Get the JSON manager of the game, used to load JSON from game resources.

Returns:
Type Description

The json manager for the game

Source:

getMinimalFramerate()

Return the minimal fps that must be guaranteed by the game (otherwise, game is slowed down).

Source:

getOriginalHeight()

Get the original height of the game, as set on the startup of the game.

This is guaranteed to never change, even if the size of the game is changed afterwards.

Source:

getOriginalWidth()

Get the original width of the game, as set on the startup of the game.

This is guaranteed to never change, even if the size of the game is changed afterwards.

Source:

getPixelsRounding()

Return if the game is rounding pixels when rendering.

Source:

getScaleMode()

Return the scale mode of the game ("linear" or "nearest").

Source:

getSceneData(sceneName)

Get the data associated to a scene.

Parameters:
Name Type Description
sceneName

The name of the scene. If not defined, the first scene will be returned.

Returns:
Type Description

The data associated to the scene.

Source:

getSceneStack()

Return the stack of gdjs.RuntimeScene being played.

Source:

getSoundManager()

Get the gdjs.SoundManager of the RuntimeGame.

Returns:
Type Description

The sound manager.

Source:

getVariables()

Get the variables of the RuntimeGame.

Returns:
Type Description

The global variables

Source:

hasScene(sceneName)

Check if a scene exists

Parameters:
Name Type Description
sceneName

The name of the scene to search.

Returns:
Type Description

true if the scene exists. If sceneName is undefined, true if the game has a scene.

Source:

isPreview()

Check if the game is running as a preview, launched from an editor.

Returns:
Type Description

true if the current game is a preview.

Source:

loadAllAssets()

Load all assets, displaying progress in renderer.

Source:

onWindowInnerSizeChanged()

Called by the game renderer when the window containing the game has changed size (this can result from a resize of the window, but also other factors like a device orientation change on mobile).

Source:

pause(enable)

Set or unset the game as paused. When paused, the game won't step and will be freezed. Useful for debugging.

Parameters:
Name Type Description
enable

true to pause the game, false to unpause

Source:

setAdaptGameResolutionAtRuntime(enable)

Set if the game resolution should be automatically adapted when the game window or screen size change. This will only be the case if the game resolution resize mode is configured to adapt the width or the height of the game.

Parameters:
Name Type Description
enable

true to change the game resolution according to the window/screen size.

Source:

setGameResolutionResizeMode(resizeMode)

Set if the width or the height of the game resolution should be changed to fit the game window - or if the game resolution should not be updated automatically.

Parameters:
Name Type Description
resizeMode

Either "" (don't change game resolution), "adaptWidth" or "adaptHeight".

Source:

setGameResolutionSize(width, height)

Change the game resolution.

Parameters:
Name Type Description
width

The new width

height

The new height

Source:

setProjectData(projectData)

Update the project data. Useful for hot-reloading, should not be used otherwise.

Parameters:
Name Type Description
projectData

The object (usually stored in data.json) containing the full project data

Source:

startCurrentSceneProfiler(onProfilerStopped)

Start a profiler for the currently running scene.

Parameters:
Name Type Description
onProfilerStopped

Function to be called when the profiler is stopped. Will be passed the profiler as argument.

Source:

startGameLoop()

Start the game loop, to be called once assets are loaded.

Source:

stopCurrentSceneProfiler()

Stop the profiler for the currently running scene.

Source:

wasFirstSceneLoaded()

Return true if a scene was loaded, false otherwise (i.e: game not yet started).

Source: