class FlxState
package flixel
extends FlxTypedContainer › FlxTypedGroup › FlxBasic
extended by FlxTransitionableState, FlxSplash, FlxSubState
This is the basic game "state" object - e.g. in a simple game you might have a menu state and a play state.
It is for all intents and purpose a fancy FlxContainer
. And really, it's not even that fancy.
Constructor
Variables
destroySubStates:Bool = true
If substates get destroyed when they are closed, setting this to
false
might reduce state creation time, at greater memory cost.
persistentDraw:Bool = true
Determines whether or not this state is updated even when it is not the active state.
For example, if you have your game state first, and then you push a menu state on top of it,
if this is set to true
, the game state would continue to be drawn behind the pause state.
By default this is true
, so background states will continue to be drawn behind the current state.
If background states are not visible
when you have a different state on top,
you should set this to false
for improved performance.
persistentUpdate:Bool = false
Determines whether or not this state is updated even when it is not the active state.
For example, if you have your game state first, and then you push a menu state on top of it,
if this is set to true
, the game state would continue to update in the background.
By default this is false
, so background states will be "paused" when they are not active.
read onlysubStateClosed:FlxTypedSignal<FlxSubState ‑> Void>
A FlxSignal
that dispatches when a sub state is closed from this state.
4.9.0
.read onlysubStateOpened:FlxTypedSignal<FlxSubState ‑> Void>
A FlxSignal
that dispatches when a sub state is opened from this state.
4.9.0
.Methods
create():Void
This function is called after the game engine successfully switches states. Override this function, NOT the constructor, to initialize or set up your game state. We do NOT recommend initializing any flixel objects or utilizing flixel features in the constructor, unless you want some crazy unpredictable things to happen!
onFocus():Void
This method is called after the game receives focus. Can be useful for third party libraries, such as tweening engines.
onFocusLost():Void
This method is called after the game loses focus. Can be useful for third party libraries, such as tweening engines.
onResize(Width:Int, Height:Int):Void
This function is called whenever the window size has been changed.
Parameters:
Width | The new window width |
---|---|
Height | The new window Height |
startOutro(onOutroComplete:() ‑> Void):Void
Called from FlxG.switchState()
, when onOutroComplete
is called, the actual state
switching will happen.
Note: Calling super.startOutro(onOutroComplete)
will call onOutroComplete
.
Parameters:
onOutroComplete | Called when the outro is complete. |
---|
5.3.0
.