Endless Runner Polymorphic Scene Manager

Endless Runner Polymorphic Scene Manager

Feb 1, 2018. | By: Ben Windley
1 min

Desired Usage

  • Ability to have one active scene and interchange it with different scene classes.
  • Make code cleaner and isolate code that doesn’t require dependancy on each other.
  • Make use of polymorphism and pointers.

Polymorphism

Scene* current_scene = nullptr;

current_scene = new MenuScene();

if (!current_scene->init(renderer.get()))
{
    return false;
}

As long as the functions called from current_scene are the inherited functions of Scene, MenuScene can override the functions as it wishes.

Social Links

linkedin