Class: RepeatForeverAction
The Action class has static methods for creating actions to be executed by an M2Node.
Extends
Constructors
new RepeatForeverAction()
new RepeatForeverAction(
action
,runDuringTransition
):RepeatForeverAction
Parameters
• action: Action
• runDuringTransition: boolean
= false
Returns
Overrides
Defined in
Action.ts:1094
Properties
children
children:
Action
[]
Immediate children of a parent action.
Inherited from
Defined in
Action.ts:1019
completedRepetitions
completedRepetitions:
number
=0
Number of completions done.
Inherited from
RepeatAction
.completedRepetitions
Defined in
Action.ts:1020
count
count:
number
=Infinity
Number of times the action will repeat.
Overrides
Defined in
Action.ts:1092
cumulativeDuration
cumulativeDuration:
number
=0
How long, in milliseconds, the repeating action has run. This is updated only at the end of a repetition.
Inherited from
RepeatAction
.cumulativeDuration
Defined in
Action.ts:1021
duration
duration:
Futurable
Inherited from
Defined in
Action.ts:38
key?
optional
key:string
Inherited from
Defined in
Action.ts:41
parent?
optional
parent:ActionContainer
Inherited from
Defined in
Action.ts:40
runDuringTransition
runDuringTransition:
boolean
Inherited from
RepeatAction
.runDuringTransition
Defined in
Action.ts:39
running
running:
boolean
=false
Inherited from
Defined in
Action.ts:31
runStartTime
runStartTime:
number
=-1
Start time of a running action is always known; it is not a Futurable
.
-1 indicates that the root action has not yet started running.
Inherited from
Defined in
Action.ts:37
started
started:
boolean
=false
Inherited from
Defined in
Action.ts:30
startOffset
startOffset:
Futurable
Inherited from
Defined in
Action.ts:29
type
type:
ActionType
=ActionType.RepeatForever
Overrides
Defined in
Action.ts:1091
Accessors
completed
Get Signature
get completed():
boolean
Indicates whether the action has completed, taking into account all its child actions and the number of repetitions.
Remarks
Is read-only for parent actions.
Returns
boolean
Inherited from
Defined in
Action.ts:1052
descendants
Get Signature
get descendants():
Action
[]
All children of a parent action and those children's children, recursively.
Returns
Action
[]
Inherited from
Defined in
Action.ts:1085
descendantsAreCompleted
Get Signature
get descendantsAreCompleted():
boolean
Returns
boolean
Inherited from
RepeatAction
.descendantsAreCompleted
Defined in
Action.ts:1059
repetitionHasCompleted
Get Signature
get repetitionHasCompleted():
boolean
Indicates whether a single repetition of a repeating action has just completed.
Returns
boolean
returns true if a repetition has completed
Inherited from
RepeatAction
.repetitionHasCompleted
Defined in
Action.ts:1069
Methods
assignRunStartTimes()
assignRunStartTimes(
action
,runStartTime
):void
Assigns RunStartTime to all actions in the hierarchy.
Parameters
• action: Action
the action to assign RunStartTime to
• runStartTime: number
Returns
void
Remarks
Uses recursion to handle arbitrary level of nesting parent actions within parent actions.
Inherited from
RepeatAction
.assignRunStartTimes
Defined in
Action.ts:650
clone()
clone():
RepeatForeverAction
Clones the action, and any actions it contains, recursively.
Returns
a clone of the action
Remarks
We need to clone an action before running it because actions
have state that is updated over time such as whether they are running or
not, etc. If we didn't clone actions, two nodes reusing the same action
would share state. On Action
, this method is abstract and is
implemented in each subclass.
Overrides
Defined in
Action.ts:1098
initialize()
initialize(
key
?):Action
Prepares the Action for evaluation.
Parameters
• key?: string
optional string to identify an action
Returns
action prepared for evaluation
Remarks
Calculates start times for all actions in the hierarchy and returns a copy of the action that is prepared for evaluation during the update loop.
Inherited from
Defined in
Action.ts:57
isParent()
isParent(
action
):action is ActionContainer
Type guard that returns true if the action is a parent action.
Parameters
• action: Action
action to check
Returns
action is ActionContainer
true if the action is a parent action
Remarks
Parent actions are Group, Sequence, Repeat, and RepeatForever actions.
Inherited from
Defined in
Action.ts:913
restartAction()
restartAction(
action
,now
):void
Configures action to be run again.
Parameters
• action: Action
action to restart
• now: number
current time
Returns
void
Remarks
This method is called on a repeating action's children when they need to be run again.
Inherited from
Defined in
Action.ts:668
shouldBeRunning()
shouldBeRunning(
now
):boolean
Determines if the action should be running.
Parameters
• now: number
current time
Returns
boolean
true if the action should be running
Remarks
An action should be running if current time is in the interval [ start time + start offset, start time + start offset + duration ]
Inherited from
Defined in
Action.ts:707
custom()
static
custom(options
):CustomAction
Creates an action that will execute a callback function.
Parameters
• options: CustomActionOptions
Returns
The custom action
Inherited from
Defined in
Action.ts:749
evaluateAction()
static
evaluateAction(action
,node
,now
,dt
):void
Evaluates an action, updating the node's properties as needed.
Parameters
• action: Action
the Action to be evaluated and possibly run
• node: M2Node
the M2Node
that the action will be run on
• now: number
the current elapsed time, from performance.now()
• dt: number
the time since the last frame (delta time)
Returns
void
Remarks
This method is called every frame by the M2Node's update()
method.
Inherited from
Defined in
Action.ts:279
fadeAlpha()
static
fadeAlpha(options
):FadeAlphaAction
Creates an action that will change the node's alpha (opacity).
Parameters
• options: FadeAlphaActionOptions
Returns
The fadeAlpha action
Remarks
Alpha has multiplicative inheritance. For example, if the node's parent is alpha .5 and this node's action fades alpha to .4, then the node will appear with alpha .2.
Inherited from
Defined in
Action.ts:798
group()
static
group(actions
):GroupAction
Create an array of actions that will be run simultaneously.
Parameters
• actions: Action
[]
One or more actions that form the group
Returns
Remarks
All actions within the group will begin to run at the same time. The group will be considered completed when the longest-running action has completed.
Inherited from
Defined in
Action.ts:871
move()
static
move(options
):MoveAction
Creates an action that will move a node to a point on the screen.
Parameters
• options: MoveActionOptions
Returns
The move action
Inherited from
Defined in
Action.ts:720
play()
static
play(options
?):PlayAction
Creates an action that will play a sound.
Parameters
• options?: PlayActionOptions
Returns
The play action
Remarks
This action can only be used with a SoundPlayer node. It will throw an error if used with any other node type.
Inherited from
Defined in
Action.ts:765
repeat()
static
repeat(options
):RepeatAction
Creates an action that will repeat another action a given number of times.
Parameters
• options: RepeatActionOptions
RepeatActionOptions
Returns
The repeat action
Inherited from
Defined in
Action.ts:883
repeatForever()
static
repeatForever(options
):RepeatForeverAction
Creates an action that will repeat another action forever.
Parameters
• options: RepeatForeverActionOptions
RepeatForeverActionOptions
Returns
The repeat forever action
Remarks
A repeat forever action is a special case of a repeat action where the count is set to infinity.
Inherited from
Defined in
Action.ts:900
rotate()
static
rotate(options
):RotateAction
Creates an action that will rotate the node.
Parameters
• options: RotateActionOptions
RotateActionOptions
Returns
The rotate action
Remarks
Rotate actions are applied to their children. In addition to this node's rotate action, all ancestors' rotate actions will also be applied.
Inherited from
Defined in
Action.ts:815
scale()
static
scale(options
):ScaleAction
Creates an action that will scale the node's size.
Parameters
• options: ScaleActionOptions
Returns
The scale action
Remarks
Scaling is relative to any inherited scaling, which is multiplicative. For example, if the node's parent is scaled to 2.0 and this node's action scales to 3.0, then the node will appear 6 times as large as original.
Inherited from
Defined in
Action.ts:780
sequence()
static
sequence(actions
):SequenceAction
Creates an array of actions that will be run in order.
Parameters
• actions: Action
[]
One or more actions that form the sequence
Returns
Remarks
The next action will not begin until the current one has finished. The sequence will be considered completed when the last action has completed.
Inherited from
Defined in
Action.ts:855
wait()
static
wait(options
):WaitAction
Creates an action that will wait a given duration before it is considered complete.
Parameters
• options: WaitActionOptions
Returns
The wait action
Inherited from
Defined in
Action.ts:736