Class: Tween

Tween


new Tween()

Source:

Extends

Members


<static, constant> ACTION_TYPES :number

Action type enums

Type:
  • number
Properties:
Name Type Default Description
REPEAT number 0
WAIT number 1
ANIMATE number 2
Source:

actions :array

List of actions.

Type:
  • array
Source:

delta :number

Delta cache for updating

Type:
  • number
Source:

duration :number

Tween duration.

Type:
  • number
Default Value:
  • 500
Source:

easing

Tween's easing function.

Properties:
Name Type Description
easing function
Source:

interpolation

Tween's interpolation function.

Properties:
Name Type Description
interpolationFn function
Source:

isFinished :boolean

Whether this tween is finished

Type:
  • boolean
Source:

isPaused :boolean

Whether this tween is paused

Type:
  • boolean
Source:

isRemoved :boolean

Whether this tween is removed

Type:
  • boolean
Source:

progress :number

Progress of current performing action

Type:
  • number
Source:

Methods


<static> create(context)

Tween factory method.

Parameters:
Name Type Description
context object

Target object.

Source:
Returns:

Tween instance.

Type
module:engine/animation/tween~Tween

<protected> _step(delta)

Update.

Parameters:
Name Type Description
delta number

Delta time

Source:

addListener()

Inherited From:
Source:

emit(event, a1, a2, a3, a4, a5)

Emit an event to all registered event listeners.

Parameters:
Name Type Description
event string

The name of the event.

a1 *

First param

a2 *

Second param

a3 *

Third param

a4 *

Forth param

a5 *

Fifth param

Inherited From:
Source:
Returns:

Indication if we've emitted an event.

Type
boolean

init(context)

Initialize this tween

Parameters:
Name Type Description
context object

Target object.

Source:

listeners(event, exists)

Return a list of assigned event listeners.

Parameters:
Name Type Description
event string

The events that should be listed.

exists boolean

We only need to know if there are listeners.

Inherited From:
Source:
Returns:

Listener list

Type
array | boolean

off()

Inherited From:
Source:

on(event, fn, context)

Register a new EventListener for the given event.

Parameters:
Name Type Description
event string

Name of the event.

fn functon

Callback function.

context Mixed

The context of the function.

Inherited From:
Source:
Returns:

Self for chaining

Type
EventEmitter

once(event, fn, context)

Add an EventListener that's only called once.

Parameters:
Name Type Description
event string

Name of the event.

fn function

Callback function.

context Mixed

The context of the function.

Inherited From:
Source:
Returns:

Self for chaining

Type
EventEmitter

pause()

Pause this tween.

Source:
Returns:

Tween itself for chaining.

Type
Tween

recycle()

Recycle this tween for later use.

Source:

removeAllListeners(event)

Remove all listeners or only the listeners for the specified event.

Parameters:
Name Type Description
event string

The event want to remove all listeners for.

Inherited From:
Source:
Returns:

Self for chaining

Type
EventEmitter

removeListener(event, fn, context, once)

Remove event listeners.

Parameters:
Name Type Description
event string

The event we want to remove.

fn function

The listener that we need to find.

context Mixed

Only remove listeners matching this context.

once boolean

Only remove once listeners.

Inherited From:
Source:
Returns:

Self for chaining

Type
EventEmitter

repeat(times)

Repeat the tween for times.

Parameters:
Name Type Description
times number

How many times to repeat.

Source:
Returns:

Tween itself.

Type
Tween

resume()

Resume this tween from pausing.

Source:
Returns:

Tween itself for chaining.

Type
Tween

stop()

Stop this tween.

Source:
Returns:

Tween itself for chaining.

Type
Tween

to(properties, duration, easing, interpolation)

Push a new action to the tween.

Parameters:
Name Type Description
properties Object

Target properties

duration Number

Duration of the action in ms

easing String | function

Easing function

interpolation String | function

Interpolation function

Source:
Returns:

Tween itself for chaining.

Type
Tween

wait(time)

Wait a short time before next action.

Parameters:
Name Type Description
time number

Time to wait in ms.

Source:
Returns:

Tween itself for chaining.

Type
Tween

Class: Tween

Tween


new Tween(context)

Parameters:
Name Type Description
context object

Object to apply this tween to.

Source:

Members


<static, constant> ACTION_TYPES :number

Action type enums

Type:
  • number
Properties:
Name Type Default Description
REPEAT number 0
WAIT number 1
ANIMATE number 2
Source:

actions :array

List of actions.

Type:
  • array
Source:

delta :number

Delta cache for updating

Type:
  • number
Source:

duration :number

Tween duration.

Type:
  • number
Default Value:
  • 500
Source:

easing

Tween's easing function.

Properties:
Name Type Description
easing function
Source:

interpolation

Tween's interpolation function.

Properties:
Name Type Description
interpolationFn function
Source:

isFinished :boolean

Whether this tween is finished

Type:
  • boolean
Source:

isPaused :boolean

Whether this tween is paused

Type:
  • boolean
Source:

isRemoved :boolean

Whether this tween is removed

Type:
  • boolean
Source:

progress :number

Progress of current performing action

Type:
  • number
Source:

Methods


<static> create(context)

Tween factory method.

Parameters:
Name Type Description
context object

Target object.

Source:
Returns:

Tween instance.

Type
module:engine/animation/tween~Tween

<protected> _step(delta)

Update.

Parameters:
Name Type Description
delta number

Delta time

Source:

addListener()

Inherited From:
Source:

emit(event, a1, a2, a3, a4, a5)

Emit an event to all registered event listeners.

Parameters:
Name Type Description
event string

The name of the event.

a1 *

First param

a2 *

Second param

a3 *

Third param

a4 *

Forth param

a5 *

Fifth param

Inherited From:
Source:
Returns:

Indication if we've emitted an event.

Type
boolean

init(context)

Initialize this tween

Parameters:
Name Type Description
context object

Target object.

Source:

listeners(event, exists)

Return a list of assigned event listeners.

Parameters:
Name Type Description
event string

The events that should be listed.

exists boolean

We only need to know if there are listeners.

Inherited From:
Source:
Returns:

Listener list

Type
array | boolean

off()

Inherited From:
Source:

on(event, fn, context)

Register a new EventListener for the given event.

Parameters:
Name Type Description
event string

Name of the event.

fn functon

Callback function.

context Mixed

The context of the function.

Inherited From:
Source:
Returns:

Self for chaining

Type
EventEmitter

once(event, fn, context)

Add an EventListener that's only called once.

Parameters:
Name Type Description
event string

Name of the event.

fn function

Callback function.

context Mixed

The context of the function.

Inherited From:
Source:
Returns:

Self for chaining

Type
EventEmitter

pause()

Pause this tween.

Source:
Returns:

Tween itself for chaining.

Type
Tween

recycle()

Recycle this tween for later use.

Source:

removeAllListeners(event)

Remove all listeners or only the listeners for the specified event.

Parameters:
Name Type Description
event string

The event want to remove all listeners for.

Inherited From:
Source:
Returns:

Self for chaining

Type
EventEmitter

removeListener(event, fn, context, once)

Remove event listeners.

Parameters:
Name Type Description
event string

The event we want to remove.

fn function

The listener that we need to find.

context Mixed

Only remove listeners matching this context.

once boolean

Only remove once listeners.

Inherited From:
Source:
Returns:

Self for chaining

Type
EventEmitter

repeat(times)

Repeat the tween for times.

Parameters:
Name Type Description
times number

How many times to repeat.

Source:
Returns:

Tween itself.

Type
Tween

resume()

Resume this tween from pausing.

Source:
Returns:

Tween itself for chaining.

Type
Tween

stop()

Stop this tween.

Source:
Returns:

Tween itself for chaining.

Type
Tween

to(properties, duration, easing, interpolation)

Push a new action to the tween.

Parameters:
Name Type Description
properties Object

Target properties

duration Number

Duration of the action in ms

easing String | function

Easing function

interpolation String | function

Interpolation function

Source:
Returns:

Tween itself for chaining.

Type
Tween

wait(time)

Wait a short time before next action.

Parameters:
Name Type Description
time number

Time to wait in ms.

Source:
Returns:

Tween itself for chaining.

Type
Tween