Class: ActionFactory

ActionFactory()

A factory class for creating Action objects.

Constructor

new ActionFactory()

Source:

Methods

(static) delay(duration) → {Action}

Create an Action that waits for a specified amount of time. This is typically used in conjunction with a sequence action.
This Action is complete once the specified amount of time passes.
Parameters:
Name Type Description
duration number amount of time to wait
Source:
Returns:
Action that waits for a specified amount of time
Type
Action

(static) destroy() → {Action}

Create an Action that automatically removes a Sprite.
This Action is complete immediately.
Source:
Returns:
Action that automatically removes a Sprite
Type
Action

(static) fadeIn(fadeDuration) → {Action}

Create an Action to fade in (increase opacity of) a Sprite over a period of time.
This Action is complete once the Sprite's opacity reaches 1.
Parameters:
Name Type Description
fadeDuration number how long (seconds) until fade is complete
Source:
Returns:
Action to fade in a Sprite over a period of time
Type
Action

(static) fadeOut(fadeDuration) → {Action}

Create an Action to fade out (reduce opacity of) a Sprite over a period of time.
This Action is complete once the Sprite's opacity reaches 0.
To automatically remove a Sprite once it has finished fading out, use:
ActionFactory.sequence([
   ActionFactory.fadeOut(fadeRate),
   ActionFactory.remove()
])
Parameters:
Name Type Description
fadeDuration number how long (seconds) until fade is complete
Source:
Returns:
Action to fade out a Sprite over a period of time
Type
Action

(static) forever(action) → {Action}

Create an Action that repeats another Action forever.
This Action is never complete.
Parameters:
Name Type Description
action Action Action to be repeated
Source:
Returns:
Action that repeats another Action forever
Type
Action

(static) isAnimationFinished() → {Action}

Create an Action that checks if animation is finished.
To remove a Sprite after its animation is complete, use:
ActionFactory.sequence([
   ActionFactory.isAnimationFinished(),
   ActionFactory.remove()
])
Source:
Returns:
Action that automatically removes a Sprite
Type
Action

(static) moveBy(deltaX, deltaY, duration) → {Action}

Create an Action to move a Sprite by a fixed amount over a period of time.
This Action is complete once movement has finished.
Parameters:
Name Type Description
deltaX number distance to move Sprite in the x-direction
deltaY number distance to move Sprite in the y-direction
duration number total time to be used for movement
Source:
Returns:
Action to move a Sprite by a fixed amount over a period of time.
Type
Action

(static) repeat(action, totalTimes) → {Action}

Create an Action that repeats another Action a fixed number of times.
This Action is complete once the specified Action has been completed the specified number of times.
Parameters:
Name Type Description
action Action Action to be repeated
totalTimes number total number of times to repeat the specified Action
Source:
Returns:
Action that repeats another Action a fixed number of times
Type
Action

(static) rotateBy(deltaAngle, duration) → {Action}

Create an Action to rotate a Sprite by a fixed amount over a period of time.
This Action is complete once rotation has finished.
Parameters:
Name Type Description
deltaAngle number angle to rotate Sprite
duration number total time to be used for movement
Source:
Returns:
Action to rotate a Sprite by a fixed amount over a period of time
Type
Action

(static) sequence(actionArray) → {Action}

Create an Action to perform a sequence of actions. Each Action in the list is performed only after all previous actions in the list have completed.
This Action is complete once all the corresponding actions are complete.
Parameters:
Name Type Description
actionArray array one or more actions to perform in sequence
Source:
Returns:
Action that performs a sequence of actions
Type
Action