Skip to content
This repository has been archived by the owner on Apr 5, 2021. It is now read-only.
Arnis Lielturks edited this page Jul 3, 2018 · 2 revisions

Levels

Switching between different scenes are created by using LevelManager. It uses fade-in/fade-out animation to go from one level to the other. Level in this case can be anything - Splash screen, Main menu, Loading screen, Game level, Game exit screen.

How to create new level?

To create new level you could look at the Source/Levels/Splash.h and Source/Levels/Splash.cpp files. New level class should extend BaseLevel class (Source/BaseLevel.h). BaseLevel class defines many methods that will be utilized by the LevelManager to allow unified interfaces for each of the levels. When your level is ready, make sure to register it in the LevelManager (Source/LevelManager.h) class in the RegisterAllFactories method.

void RegisterAllFactories()
{
  context_->RegisterFactory<Levels::Splash>();
}

When that's done, you can switch between levels by using the following code.

VariantMap data;
eventData["Name"] = "Splash";
SendEvent(MyEvents::E_SET_LEVEL, eventData);

You can also pass additional parameters for the new level

VariantMap data;
eventData["Name"] = "Splash";
eventData["Param1"] = 123;
SendEvent(MyEvents::E_SET_LEVEL, eventData);

So when your level is initialized, LevelManager will pass all the arguments and they will become available in the Init() method. From there you could retrieve them like this:

void Splash::Init()
{
  int value = data_["Param1].GetInt();
}
Clone this wiki locally