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 the current state is drawn, even when it is not the active state.
For example, if you have your game state open first, and then you push a pause state on top of it,
if this is set to true
, the game state would still continue to be drawn behind that pause state.
By default, this is set to true
, so the background states will continue to be "drawn" behind the current state.
If you do not want background states to be visible
when you have a different state on top,
then you should set this to false
for improved performance.
persistentUpdate:Bool = false
Determines whether the current state is updated, even when it is not the active state.
For example, if you have your game state open first, and then you push a pause state on top of it,
if this is set to true
, the game state would still continue to be updated in the background.
By default, this is set to false
, so the background states will continue to 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
.