API Documentation for: 1.0.1
Show:

platypus.components.Tween Class

This component takes a list of tween definitions and plays them as needed. This component requires CreateJS Tween.

NOTE: This component handles ticking that's synchronized with the game's tick, NOT it's logic tick. As such, reading tweened values during the logic tick will show a changed value on the first logic tick, but all subsequent logic ticks comprising the game's full tick will show no change at all.

Methods

addEventListener

(
  • event
  • callback
)
Function private
This method adds an event listener to the entity.

Parameters:

  • event String
    The event that this component should listen for.
  • callback Function
    The handler for the event.

Returns:

Function: handler A reference to the bound handler.

addMethod

(
  • name
  • func
)
private
This method adds a method to the entity.

Parameters:

  • name String
    The name of the method. For example, if name is "turnYellow", the method is accessible on the entity as entity.turnYellow().
  • func Function
    The function describing the method.

destroy

() private

Inherited from platypus.Component: destroy:54

This method cleans up listeners and methods that this component added to the entity. It should never be called by the component itself. Call this.owner.removeComponent(this) instead.

getAssetList

(
  • definition
  • properties
  • defaultProperties
)
Array
This method can be overwritten to provide the list of assets this component requires. This method is invoked when the list of game scenes is created to determine assets for each scene.

Parameters:

  • definition Object
    The definition for the component.
  • properties Object
    The properties of the Entity.
  • defaultProperties Object
    The default properties of the Entity.

Returns:

Array: A list of the necessary assets to load.

getLateAssetList

(
  • data
)
Array
This method can be overwritten to provide the list of assets this component requires. This method is invoked when the list of game scenes is created to determine assets for each scene.

Parameters:

  • data Object
    Scene data that affects the list of assets.

Returns:

Array: A list of the necessary assets to load.

removeEventListener

(
  • event
  • callback
)
private
This method removes an event listener from the entity.

Parameters:

  • event String
    The event for which to remove a listener.
  • callback Function
    The listener to remove. If not supplied, all event listeners for the provided event are removed.

removeEventListeners

(
  • [listeners]
)
private
This method removes multiple event listeners from the entity.

Parameters:

  • [listeners] Array optional
    The list of listeners to remove. If not supplied, all event listeners are removed.

removeMethod

(
  • name
)
private
This method removes a method from the entity.

Parameters:

  • name String
    The name of the method to be removed.

toJSON

() Object

Inherited from platypus.Component: toJSON:45

Available since 0.11.0

Returns a JSON object describing the component.

Returns:

Object: Returns a JSON definition that can be used to recreate the component.

toString

() String
Returns a string describing the component.

Returns:

String: Returns the component type as a string of the form "[Component ComponentType]".

Properties

bounce

Boolean

Defined in bounce:180

Sets bounce on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: false

events

Object

Defined in events:120

Required. A key/value list of events and an array or object representing the tween they should trigger.

 {
                                                 "begin-flying": [ // When "begin-flying" is triggered on this entity, the following tween begins. Tween definitions adhere to a similar structure outlined by the TweenJS documentation. Each milestone on the tween is an item in this array.
                                                     ["to", { // If the definition is an array, the first parameter is the type of milestone, in this case "to", with all following parameters passed directly to the equivalent Tween function.
                                                         "scaleY": 1,
                                                         "y": 400
                                                     }, 500],
                                                     ["call", "fly"], // "call" milestones can take a function or a string. If it's a string, the string will be triggered as an event on the entity. In this case, the component will trigger "fly".
                                                 ],
                                            
                                                 "stop-flying": { // Alternatively, an object can be used to include properties. It must include a tween property with an array of tween values like above. It may include any properties that the Tween component accepts and overrides the component's properties.
                                                     "tween": [["to", {"y": 0}, 250]],
                                                     "loop": 2 // This overrides this component's loop property value.
                                                 }
                                             }

Default: null

ignoreGlobalPause

Boolean

Sets ignoreGlobalPause on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: false

loop

Number | Boolean

Defined in loop:162

Sets loop on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: 0

onChange

Function | String

Defined in onChange:225

Sets onChange on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html. If a string is specified, it is triggered as an event on the entity.

Default: ''

onComplete

Function | String

Defined in onComplete:234

Sets onComplete on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html. If a string is specified, it is triggered as an event on the entity.

Default: ''

override

Boolean

Defined in override:243

Sets override on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: false

paused

Boolean

Defined in paused:207

Sets paused on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: false

pluginData

Object

Defined in pluginData:198

Sets pluginData on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: null

position

Number

Defined in position:216

Sets position on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: false

reversed

Boolean

Defined in reversed:171

Sets reversed on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: false

timeScale

Number

Defined in timeScale:189

Sets timeScale on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: 1

useTicks

Boolean

Defined in useTicks:144

Sets useTicks on the tween as defined here: https://www.createjs.com/docs/tweenjs/classes/Tween.html

Default: false