Constructors

Path

Constructor Summary

Path

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

Fields Summary

Functions Summary

Path.addNode (node)

Add a node to the path.
Path.clone ()

Create a clone of the path
Path.debugDraw (toggle, layerId)

Create sprites to provide a visual representation of the path
Path.evaluate (sceneObject, time)

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

Get the name of the path
Path.getNode (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.
Path.getNodeCount ()

Get the current number of nodes in the path
Path.getNodeRef (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.
Path.getNodes ()

Get a copy of the nodes array
Path.isInScene ()

Check whether the path is currently in the scene
Path.removeNode (nodeIndex)

Remove a node from the array of nodes
Path.serialize (stringify)

Create an object representation of the path. This can be used to construct a new path, passing it directly into the Path constructor.
Path.setFromSceneObject (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.
Path.setName (name)

Set a name for this path
Path.setNode (nodeIndex, nodeData)

Set a node in the path
Path.setNodes (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.

Constructor Details

Path

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.

Array|object nodes (optional): 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 name (optional): 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
}

Fields Details

Function Details

Path.addNode (node)

Add a node to the path.

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

Path.clone ()

Create a clone of the path

Returns Path : A new Path object

Path.debugDraw (toggle, layerId)

Create sprites to provide a visual representation of the path

boolean toggle (optional): Whether to enable or disable debug drawing. If omitted, this parameter is assumed to be true.


number layerId (optional): 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.

Path.evaluate (sceneObject, time)

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

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

Path.getName ()

Get the name of the path

Returns : {string}

Path.getNode (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.

number nodeIndex (optional): The index of the node. If omitted, the first node will be returned.


Returns Object : A copy of the node data

Path.getNodeCount ()

Get the current number of nodes in the path

Returns Number : The number of nodes in the path

Path.getNodeRef (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.

number nodeIndex (optional): The index of the node. If omitted, the first node will be returned.


Returns Object : The node data

Path.getNodes ()

Get a copy of the nodes array

Returns Array : A copy of the nodes array

Path.isInScene ()

Check whether the path is currently in the scene

Returns boolean : Whether the path is currently in the scene

Path.removeNode (nodeIndex)

Remove a node from the array of nodes

number [nodeIndex : = 0] The index of the node to remove

Path.serialize (stringify)

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

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.

Path.setFromSceneObject (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.

SceneObject sceneObject : The SceneObject to use


number [nodeIndex : = 0] The index of the node that you want to modify

Path.setName (name)

Set a name for this path

string name : The name to set

Path.setNode (nodeIndex, nodeData)

Set a node in the path

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.
Path.setNodes (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.

Array nodes : The array of nodes to use.