class FlxTransitionableState
package flixel.addons.transition
extends FlxState › FlxTypedContainer › FlxTypedGroup › FlxBasic
extended by FlxUIState
@:build(flixel.system.macros.FlxMacroUtil.deprecateOverride("switchTo", "switchTo is deprecated, use startOutro"))@:autoBuild(flixel.system.macros.FlxMacroUtil.deprecateOverride("switchTo", "switchTo is deprecated, use startOutro"))A FlxState
which can perform visual transitions
Usage:
First, extend FlxTransitionableState
as ie, FooState
.
Method 1:
var in:TransitionData = new TransitionData(...); // add your data where "..." is
var out:TransitionData = new TransitionData(...);
FlxG.switchState(new FooState(in,out));
Method 2:
FlxTransitionableState.defaultTransIn = new TransitionData(...);
FlxTransitionableState.defaultTransOut = new TransitionData(...);
FlxG.switchState(new FooState());
Static variables
Constructor
new(?TransIn:TransitionData, ?TransOut:TransitionData)
Create a state with the ability to do visual transitions
Parameters:
TransIn | Plays when the state begins |
---|---|
TransOut | Plays when the state ends |
Variables
Methods
transitionOut(?OnExit:() ‑> Void):Void
Starts the out-transition. Can be called manually at any time.
Inherited Variables
Defined by FlxState
@:value(true)destroySubStates:Bool = true
If substates get destroyed when they are closed, setting this to
false
might reduce state creation time, at greater memory cost.
@:value(true)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.
@:value(false)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
.Defined by FlxTypedGroup
@:value(0)read onlylength:Int = 0
The number of entries in the members array. For performance and safety you should check this
variable instead of members.length
unless you really know what you're doing!
maxSize:Int
The maximum capacity of this group. Default is 0
, meaning no max capacity, and the group can just grow.
read onlymemberAdded:FlxTypedSignal<T ‑> Void>
A FlxSignal
that dispatches when a child is added to this group.
4.4.0
.read onlymemberRemoved:FlxTypedSignal<T ‑> Void>
A FlxSignal
that dispatches when a child is removed from this group.
4.4.0
.Defined by FlxBasic
@:value(idEnumerator++)ID:Int = idEnumerator++
A unique ID starting from 0 and increasing by 1 for each subsequent FlxBasic
that is created.
@:value(true)alive:Bool = true
Useful state for many game objects - "dead" (!alive
) vs alive
. kill()
and
revive()
both flip this switch (along with exists
, but you can override that).
cameras:Array<FlxCamera>
This determines on which FlxCamera
s this object will be drawn. If it is null
/ has not been
set, it uses the list of default draw targets, which is controlled via FlxG.camera.setDefaultDrawTarget
as well as the DefaultDrawTarget
argument of FlxG.camera.add
.
read onlycontainer:Null<FlxContainer>
The parent containing this basic, typically if you check this recursively you should reach the state
5.7.0
.Inherited Methods
Defined by FlxState
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.
Defined by FlxTypedGroup
add(basic:T):T
Adds a new FlxBasic
subclass (FlxBasic
, FlxSprite
, Enemy
, etc) to the group.
FlxGroup
will try to replace a null
member of the array first.
Failing that, FlxGroup
will add it to the end of the member array.
WARNING: If the group has a maxSize
that has already been met,
the object will NOT be added to the group!
Parameters:
basic | The |
---|
Returns:
The same FlxBasic
object that was passed in.
any(func:T ‑> Bool):Bool
Tests whether any member satisfies the function.
Parameters:
func | The function that tests the members |
---|
5.4.0
.clear():Void
Remove all instances of FlxBasic
subclasses (FlxSprite
, FlxTileblock
, etc) from the list.
WARNING: does not destroy()
or kill()
any of these objects!
countDead():Int
Call this function to find out how many members of the group are dead.
Returns:
The number of FlxBasic
s flagged as dead. Returns -1
if group is empty.
countLiving():Int
Call this function to find out how many members of the group are not dead.
Returns:
The number of FlxBasic
s flagged as not dead. Returns -1
if group is empty.
every(func:T ‑> Bool):Bool
Tests whether every member satisfies the function.
Parameters:
func | The function that tests the members |
---|
5.4.0
.@:value({ recurse : false })forEach(func:T ‑> Void, recurse:Bool = false):Void
Applies a function to all members.
Parameters:
func | A function that modifies one element at a time. |
---|---|
recurse | Whether or not to apply the function to members of subgroups as well. |
@:value({ recurse : false })forEachAlive(func:T ‑> Void, recurse:Bool = false):Void
Applies a function to all alive
members.
Parameters:
func | A function that modifies one element at a time. |
---|---|
recurse | Whether or not to apply the function to members of subgroups as well. |
@:value({ recurse : false })forEachDead(func:T ‑> Void, recurse:Bool = false):Void
Applies a function to all dead members.
Parameters:
func | A function that modifies one element at a time. |
---|---|
recurse | Whether or not to apply the function to members of subgroups as well. |
@:value({ recurse : false })forEachExists(func:T ‑> Void, recurse:Bool = false):Void
Applies a function to all existing members.
Parameters:
func | A function that modifies one element at a time. |
---|---|
recurse | Whether or not to apply the function to members of subgroups as well. |
@:value({ recurse : false })forEachOfType<K>(objectClass:Class<K>, func:K ‑> Void, recurse:Bool = false):Void
getFirst(func:T ‑> Bool):Null<T>
Searches for, and returns the first member that satisfies the function.
Parameters:
func | The function that tests the members |
---|
5.4.0
.getFirstAlive():Null<T>
@:value({ force : false })getFirstAvailable(?objectClass:Class<T>, force:Bool = false):Null<T>
Call this function to retrieve the first object with exists == false
in the group.
This is handy for recycling in general, e.g. respawning enemies.
Parameters:
objectClass | An optional parameter that lets you narrow the results to instances of this particular class. |
---|---|
force | Force the object to be an |
Returns:
A FlxBasic
currently flagged as not existing.
getFirstDead():Null<T>
getFirstExisting():Null<T>
getFirstIndex(func:T ‑> Bool):Int
Searches for, and returns the index of the first member that satisfies the function.
Parameters:
func | The function that tests the members |
---|
5.4.0
.getFirstNull():Int
Call this function to retrieve the first index set to null
.
Returns -1
if no index stores a null
object.
Returns:
An Int
indicating the first null
slot in the group.
getLast(func:T ‑> Bool):Null<T>
Searches for, and returns the last member that satisfies the function.
Parameters:
func | The function that tests the members |
---|
5.4.0
.getLastIndex(func:T ‑> Bool):Int
Searches for, and returns the index of the last member that satisfies the function.
Parameters:
func | The function that tests the members |
---|
5.4.0
.@:value({ length : 0, startIndex : 0 })getRandom(startIndex:Int = 0, length:Int = 0):T
Returns a member at random from the group.
Parameters:
startIndex | Optional offset off the front of the array.
Default value is |
---|---|
length | Optional restriction on the number of values you want to randomly select from. |
Returns:
A FlxBasic
from the members
list.
insert(position:Int, object:T):T
Inserts a new FlxBasic
subclass (FlxBasic
, FlxSprite
, Enemy
, etc)
into the group at the specified position.
FlxGroup
will try to replace a null
member at the specified position of the array first.
Failing that, FlxGroup
will insert it at the position of the member array.
WARNING: If the group has a maxSize
that has already been met,
the object will NOT be inserted to the group!
Parameters:
position | The position in the group where you want to insert the object. |
---|---|
object | The object you want to insert into the group. |
Returns:
The same FlxBasic
object that was passed in.
killMembers():Void
Calls kill()
on the group's unkilled members
. Revive them via reviveMembers()
.
5.4.0
.@:value({ revive : true, force : false })recycle(?objectClass:Class<T>, ?objectFactory:() ‑> T, force:Bool = false, revive:Bool = true):T
Recycling is designed to help you reuse game objects without always re-allocating or "newing" them.
It behaves differently depending on whether maxSize
equals 0
or is bigger than 0
.
maxSize > 0
/ "rotating-recycling" (used by FlxEmitter
):
- at capacity: returns the next object in line, no matter its properties like alive
, exists
etc.
- otherwise: returns a new object.
maxSize == 0
/ "grow-style-recycling"
- tries to find the first object with exists == false
- otherwise: adds a new object to the members
array
WARNING: If this function needs to create a new object, and no object class was provided,
it will return null
instead of a valid object!
Parameters:
objectClass | The class type you want to recycle (e.g. |
---|---|
objectFactory | Optional factory function to create a new object
if there aren't any dead members to recycle.
If |
force | Force the object to be an |
revive | Whether recycled members should automatically be revived
(by calling |
Returns:
A reference to the object that was created.
@:value({ splice : false })remove(basic:T, splice:Bool = false):T
Removes an object from the group.
Parameters:
basic | The |
---|---|
splice | Whether the object should be cut from the array entirely or not. |
Returns:
The removed object.
replace(oldObject:T, newObject:T):T
Replaces an existing FlxBasic
with a new one.
Does not do anything and returns null
if the old object is not part of the group.
Parameters:
oldObject | The object you want to replace. |
---|---|
newObject | The new object you want to use instead. |
Returns:
The new object.
reviveMembers():Void
Calls revive()
on the group's killed members and then on the group itself.
5.4.0
.@:value({ order : FlxSort.ASCENDING })inlinesort(func:(Int, T, T) ‑> Int, order:Int = FlxSort.ASCENDING):Void
Call this function to sort the group according to a particular value and order.
For example, to sort game objects for Zelda-style overlaps you might call
group.sort(FlxSort.byY, FlxSort.ASCENDING)
at the bottom of your FlxState#update()
override.
Parameters:
func | The sorting function to use - you can use one of the premade ones in
|
---|---|
order | A constant that defines the sort order.
Possible values are |
Defined by FlxBasic
getCameras():Array<FlxCamera>
The cameras that will draw this. Use this.cameras
to set specific cameras for this object,
otherwise the container's cameras are used, or the container's container and so on. If there
is no container, say, if this is inside FlxGroups
rather than a FlxContainer
then the
default draw cameras are returned.
5.7.0
.