Inherited: ObjectSystem


The Engine class is one of the central parts of the Thunder Engine. This class is created first and removed last in your game. It is responsible for many basic functions, such as game cycle, management of game modules, loading and unloading of game resources, work with game settings.

Public Methods

Engine (File * file, const char * path)

~Engine ()

Static Methods


addModule (Module * module)


applicationName ()

Actor *

composeActor (const std::string & component, const std::string & name, Object * parent = nullptr)

File *

file ()


init ()


isGameMode ()


isResourceExist (const std::string & path)

Object *

loadResource (const std::string & path)

Scene *

loadScene (const std::string & path, bool additive)


loadTranslator (const std::string & name)


locationAppConfig ()


locationAppDir ()


organizationName ()


reference (Object * object)


reloadBundle ()


reloadResource (const std::string & path)

RenderSystem *

renderSystem ()

ResourceSystem *

resourceSystem ()


setGameMode (bool flag)


setPlatformAdaptor (PlatformAdaptor * platform)


setResource (Object * object, const std::string & uuid)


setValue (const std::string & key, const Variant & value)


start ()


syncValues ()


translate (const std::string & source)


unloadAllScenes ()


unloadResource (const std::string & path)


unloadResource (Resource * resource)


unloadScene (Scene * scene)


update ()


value (const std::string & key, const Variant & defaultValue = Variant())

World *

world ()

Methods Description

Engine::Engine (File * file, char * path)

Constructs Engine. Using file and path parameters creates necessary platform adapters, register basic component types and resource types.

Engine::~Engine ()

Destructs Engine, related objects, registered object factories and platform adaptor.

void Engine::addModule (Module * module)

Adds a game module to pool. This module will be used during update() method execution.


if(engine->init()) {
    engine->addModule(new RenderGL(engine));


std::string Engine::applicationName ()

Returns application name.

Actor * parent = nullptr)

Creates an Actor with name and attached component. Created Actor will be added to the hierarchy of parent. This method helps to create all dependencies for the component.

Warning: This method should be used only in Editor mode.

:ref:`File<api_File>`* Engine::file ()

Returns file system module.

bool Engine::init ()

Initializes all engine systems. Returns true if successful; otherwise returns false.

bool Engine::isGameMode ()

Returns true if game started; otherwise returns false.

bool Engine::isResourceExist (std::string & path)

Returns true if resource with path exists; otherwise returns false.

:ref:`Object<api_Object>`* Engine::loadResource (std::string & path)

Returns an instance for loading resource by the provided path.

Note: In case of resource was loaded previously this function will return the same instance.

See also unloadResource().

:ref:`Scene<api_Scene>`* Engine::loadScene (std::string & path, bool additive)

Loads the scene stored in the .map files by the it’s path to the Engine.

Note: The previous scenes will be not unloaded in the case of an additive flag is true.

bool Engine::loadTranslator (std::string & name)

Loads translation table with provided file name. This method generates the LanguageChange event for the Engine instance. An Engine instance will propagate the event to all top-level widgets, where reimplementation of event() can re-translate user-visible strings. Returns true on success; otherwise returns false.

std::string Engine::locationAppConfig ()

Returns path to application config directory.

std::string Engine::locationAppDir ()

Returns path to application binary directory.

std::string Engine::organizationName ()

Returns organization name.

std::string Engine::reference (Object * object)

Returns resource path for the provided resource object.

See also setResource().

bool Engine::reloadBundle ()

This method reads the index file for the resource bundle. The index file helps to find required game resources. Returns true in case of success; otherwise returns false.

void Engine::reloadResource (std::string & path)

Reloads the resource located along the path.

See also loadResource().

:ref:`RenderSystem<api_RenderSystem>`* Engine::renderSystem ()

Returns the render system which can be used in external modules.

:ref:`ResourceSystem<api_ResourceSystem>`* Engine::resourceSystem ()

Returns the resource management system which can be used in external modules.

void Engine::setGameMode (bool flag)

Set game flag to true if game started; otherwise set false.

See also isGameMode().

void Engine::setPlatformAdaptor (PlatformAdaptor * platform)

Replaces a current platform adaptor with new one;

Note: The previous one will not be deleted.

void Engine::setResource (Object * object, std::string & uuid)

Register resource object by uuid path.

See also setResource().

void Engine::setValue (std::string & key, Variant & value)

Sets the value of setting key to value. If the key already exists, the previous value will be overwritten.

See also *value*().

bool Engine::start ()

Starts the main game cycle. Also this method loads the first level of your game. Returns true if successful; otherwise returns false.

void Engine::syncValues ()

Applies all unsaved settings.

std::string Engine::translate (std::string & source)

Returns the translation text for the source string.

void Engine::unloadAllScenes ()

Unloads all scenes from the World.

void Engine::unloadResource (std::string & path)

Forcely unloads the resource located along the path from memory.

Warning: After this call, the reference on the resource may become an invalid at any time and must not be used anymore.

See also loadResource().

void Engine::unloadResource (Resource * resource)

Forcely unloads the resource from memory.

Warning: After this call, the reference on the resource may become an invalid at any time and must not be used anymore.

See also loadResource().

void Engine::unloadScene (Scene * scene)

Unloads the scene from the World.

void Engine::update ()

This method launches all your game modules responsible for processing all the game logic. It calls on each iteration of the game cycle.

Note: Usually, this method calls internally and must not be called manually.

Variant Engine::value (std::string & key, Variant & defaultValue = Variant())

Returns the value for setting key. If the setting doesn’t exist, returns defaultValue.

See also setValue().

:ref:`World<api_World>`* Engine::world ()

Returns game World.

Note: The game can have only one scene graph. World is a root object, all map loads on this World.