Class: ScaleAction
The Action class has static methods for creating actions to be executed by an M2Node.
Extends
Constructors
new ScaleAction()
new ScaleAction(
scale,duration,runDuringTransition):ScaleAction
Parameters
• scale: number
• duration: Futurable
• runDuringTransition: boolean = false
Returns
Overrides
Defined in
m2c2kit/packages/core/src/Action.ts:1225
Properties
delta
delta:
number=0
Defined in
m2c2kit/packages/core/src/Action.ts:1223
duration
duration:
Futurable
Inherited from
Defined in
m2c2kit/packages/core/src/Action.ts:39
key?
optionalkey:string
Inherited from
Defined in
m2c2kit/packages/core/src/Action.ts:42
parent?
optionalparent:ActionContainer
Inherited from
Defined in
m2c2kit/packages/core/src/Action.ts:41
runDuringTransition
runDuringTransition:
boolean
Inherited from
Defined in
m2c2kit/packages/core/src/Action.ts:40
running
running:
boolean=false
Inherited from
Defined in
m2c2kit/packages/core/src/Action.ts:32
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
m2c2kit/packages/core/src/Action.ts:38
scale
scale:
number
Defined in
m2c2kit/packages/core/src/Action.ts:1222
started
started:
boolean=false
Inherited from
Defined in
m2c2kit/packages/core/src/Action.ts:31
startOffset
startOffset:
Futurable
Inherited from
Defined in
m2c2kit/packages/core/src/Action.ts:30
type
type:
ActionType=ActionType.Scale
Overrides
Defined in
m2c2kit/packages/core/src/Action.ts:1221
Accessors
completed
Get Signature
get completed():
boolean
Indicates whether the action has completed.
Returns
boolean
Set Signature
set completed(
value):void
Parameters
• value: boolean
Returns
void
Inherited from
Defined in
m2c2kit/packages/core/src/Action.ts:948
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
Defined in
m2c2kit/packages/core/src/Action.ts:651
clone()
clone():
ScaleAction
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
m2c2kit/packages/core/src/Action.ts:1230
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
m2c2kit/packages/core/src/Action.ts:58
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
m2c2kit/packages/core/src/Action.ts:918
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
m2c2kit/packages/core/src/Action.ts:669
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
m2c2kit/packages/core/src/Action.ts:708
custom()
staticcustom(options):CustomAction
Creates an action that will execute a callback function.
Parameters
• options: CustomActionOptions
Returns
The custom action
Inherited from
Defined in
m2c2kit/packages/core/src/Action.ts:750
evaluateAction()
staticevaluateAction(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
m2c2kit/packages/core/src/Action.ts:280
fadeAlpha()
staticfadeAlpha(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
m2c2kit/packages/core/src/Action.ts:799
group()
staticgroup(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
m2c2kit/packages/core/src/Action.ts:876
move()
staticmove(options):MoveAction
Creates an action that will move a node to a point on the screen.
Parameters
• options: MoveActionOptions