Im trying to make simple ingame menu. Im using FlxSubState class. First im trying invoke substate in main game state with openSubState(gameMenu);
after pressing Esc.
There is code in my substate class, this class inheriting FlxSubState
:
override public function create():Void
{
super.create();
continueButton = new FlxButton(0,0, "Continue", continueGame);
continueButton.x = FlxG.width / 2 - continueButton.width / 2;
continueButton.y = FlxG.height / 2 - continueButton.height / 2;
add(continueButton);
}
private function continueGame():Void
{
close();
}
Problem is : everytime after click on continueButton
game crash with null exception in FlxTypedGroup
. I think its in close();
method but i really cannot figure it out. Can anyone help me ?
Or suggest better way to implement ingame menu ?
Figured it out by myself. Looks like that after closing substate is destroyed. So something like this
override public function create():Void
{
super.create();
gameMenu = new MySubstate();
}
using with this
openSubState(gameMenu);
wont work.
Instead i need to create new substate directly
openSubState(new MySubstate());