Hello everyone!
I’m currently trying to implement a simple SceneManager. I’m new to OpenFL and Haxe so I don’t really know how to do it because my latest attempts failed. Here is one of my attempts:
package;
import openfl.display.Sprite;
import openfl.display.DisplayObject;
import openfl.Lib;
class SceneManager extends Sprite
{
private var currentScene: DisplayObject;
public function new(rootScene: DisplayObject)
{
super();
currentScene = rootScene;
Lib.current.addChild(currentScene);
}
public function changeScene(newScene: DisplayObject): Void
{
Lib.current.removeChild(currentScene);
currentScene = newScene;
Lib.current.addChild(currentScene);
}
}
If anyone can help me I would be really grateful.
Thank you!