A utility type that allows methods to accept multiple types, when dealing with "future" FlxStates. Prior to haxeFlixel 6, the FlxGame constructor took a FlxState class which meant initial FlxStatescould not have constructor args. In version 6.0.0 and higher, it now takes a function that returns a newly created instance.

examples:

You can pass the state's contructor in directly:

FlxG.switchState(PlayState.new);

You can use short lambas (arrow functions) that return a newly created instance:

var levelID = 1;
FlxG.switchState(()->new PlayState(levelID));

You can do things the long way, and use an anonymous function:

FlxG.switchState(function () { return new PlayState(); });

[Deprecated] Lastly, you can use the old way and pass in a type (until it's removed):

FlxG.switchState(PlayState);
Available since

5.6.0

.

See also:

Static methods

@:fromstaticfromMaker(func:() ‑> FlxState):InitialState

@:fromstaticfromType(state:Class<FlxState>):InitialState

@:tostatictoNextState(this:Dynamic):NextState