Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the way FlxStates are called #2565

Closed
wants to merge 9 commits into from
Prev Previous commit
Next Next commit
adding the FlxSplash switch state thingy
Cheemsandfriends authored May 27, 2022
commit f69464ceb01f3dec16d56539d548670aa5d86e5a
2 changes: 1 addition & 1 deletion flixel/system/FlxSplash.hx
Original file line number Diff line number Diff line change
@@ -199,7 +199,7 @@ class FlxSplash extends FlxState
#end
FlxG.stage.removeChild(_sprite);
FlxG.stage.removeChild(_text);
FlxG.switchState(Type.createInstance(nextState, []));
FlxG.switchState(() -> Type.createInstance(nextState, []));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nextState should also be a ()->FlxState, and the FlxGame constructor should take a function instead of a Class Ref

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm So like making the PlayState.new also in FlxGame?
I liked that you didn't need to add anything, just the name but ok

Copy link
Member

@Geokureli Geokureli May 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where before you had

addChild(new FlxGame(400, 300, MenuState);

now you can just do

addChild(new FlxGame(400, 300, MenuState.new);

the reason for this is to allow constuctor args, like

addChild(new FlxGame(400, 300, MenuState.new.bind(arg));

FlxG.game._gameJustStarted = true;
}
}