Constructors

- Path

Constructor Summary

Path
(nodes,
name)
A Path is a collection of nodes that a scene object can be told to follow.

Functions Summary

addNode
(node)
Add a node to the path.
clone()
Create a clone of the path
debugDraw
(toggle,
layerId)
Create sprites to provide a visual representation of the path
evaluate
(sceneObject,
time)
Evaluate the properties of the path at the specified time, and apply them to a SceneObject.
Path.
getDebugDrawObject()
Get the object that is being used for the debug drawing of this path (if enabled).
Get the name of the path
getNode
(nodeIndex)
Get the data for a node in the path.
Get the current number of nodes in the path
getNodeRef
(nodeIndex)
Get the data for a node in the path.
Get a copy of the nodes array
Check whether the path is currently in the scene
removeNode
(nodeIndex)
Remove a node from the array of nodes
serialize
(stringify)
Create an object representation of the path.
setFromSceneObject
(sceneObject,
nodeIndex)
Set the properties of a node based on the current values present in a SceneObject.
setName
(name)
Set a name for this path
setNode
(nodeIndex,
nodeData)
Set a node in the path
setNodes
(nodes)
Set an array of nodes that this path will use.

Constructor Details


(nodes,
name)
A Path is a collection of nodes that a scene object can be told to follow. Any values between nodes (not just position but opacity, size, rotation and any custom properties) are interpolated using a method that you can change per node. When a SceneObject is on a Path segment, any properties that are present on both the start and end node of that segment are interpolated and applied to the object and all of its sprites.

Parameters:


{Array|object}nodesOptional
An array of nodes (see setNode for a definition of the data structure of each node). You can also use this constructor by passing in a single object (so just the first parameter) that contains all the Path properties that you want to set (see remarks below for more details).
{string}nameOptional
The name of the path. This can be used to refer to the path using wade.getPath(pathName).

Remarks:
You can also use this constructor by passing in a single object (so just the first parameter) that contains all the Path properties that you want to set. In this case, the object structure is as follows (all fields are optional):
 {
 	type: 'Path',
 	nodes: Array,
 	name: string
 }

Function Details


(node)
Add a node to the path.

Parameters:


{object}node
A node data structure. See the documentation of setNode for mode details.

Returns:


{Number}
The index of the node in the nodes array
()
Create a clone of the path

Returns:


{Path}
A new Path object

(toggle,
layerId)
Create sprites to provide a visual representation of the path

Parameters:


{boolean}toggleOptional
Whether to enable or disable debug drawing. If omitted, this parameter is assumed to be true.
{number}layerIdOptional
The layer that the sprites will use. By default this is 1.

Returns:


{SceneObject}
A SceneObject that contains all the sprites needed for the debug draw.

(sceneObject,
time)
Evaluate the properties of the path at the specified time, and apply them to a SceneObject.

Parameters:


{SceneObject}sceneObject
The SceneObject to apply the properties to
{number}time
The path time

Returns:


{number}
The index of the node that marks the start of the segment for the specified time

Get the object that is being used for the debug drawing of this path (if enabled).

Returns:


{SceneObject|null}
The SceneObject that contains all the debug draw sprites, or null if debug drawing isn't enabled
()
Get the name of the path

Returns:


{string}

(nodeIndex)
Get the data for a node in the path. Note that this is a copy of the data, if you want to access the node object that is in the path directly, please use getNodeRef.

Parameters:


{number}nodeIndexOptional
The index of the node. If omitted, the first node will be returned.

Returns:


{Object}
A copy of the node data
()
Get the current number of nodes in the path

Returns:


{Number}
The number of nodes in the path

(nodeIndex)
Get the data for a node in the path. Note that this is NOT a copy of the data, but a reference to it.

Parameters:


{number}nodeIndexOptional
The index of the node. If omitted, the first node will be returned.

Returns:


{Object}
The node data
()
Get a copy of the nodes array

Returns:


{Array}
A copy of the nodes array
()
Check whether the path is currently in the scene

Returns:


{boolean}
Whether the path is currently in the scene

(nodeIndex)
Remove a node from the array of nodes

Parameters:


{number}nodeIndexOptional, Default: 0
The index of the node to remove

(stringify)
Create an object representation of the path. This can be used to construct a new path, passing it directly into the Path constructor.

Parameters:


{boolean}stringify
Whether a string representation of the object should be returned, rather than the object itself

Returns:


{object}
An object representation of the path.

(sceneObject,
nodeIndex)
Set the properties of a node based on the current values present in a SceneObject. This function looks at the properties that are defined on the next node to determine which properties should be affected in the current node.

Parameters:


{SceneObject}sceneObject
The SceneObject to use
{number}nodeIndexOptional, Default: 0
The index of the node that you want to modify

(name)
Set a name for this path

Parameters:


{string}name
The name to set

(nodeIndex,
nodeData)
Set a node in the path

Parameters:


{number}nodeIndex
The index of the node to change
{object}nodeData
The data to set for the node. This is an object that can contain any of the following fields (all optional):
{
tweenType: string - it can be 'linear', 'quadratic', 'cubic', 'quartic', 'quintic', 'sinusoidal', 'exponential', 'circular'
position: {x: number, y: number},
size: {x: number, y: number},
opacity: number,
rotation: number,
properties: {}
}
Where properties is an object that can contain any number of custom fields.

(nodes)
Set an array of nodes that this path will use. See setNode for a definition of the data structure to use for each node.

Parameters:


{Array}nodes
The array of nodes to use.