Classes


Class Path

Class Summary
Constructor Attributes Constructor Name and Description
 
Path(nodes, name)
A Path is a collection of nodes that a scene object can be told to follow.
Method Summary
Method Attributes Method Name and Description
 
addNode(node)
Add a node to the path.
 
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.
<static>  
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.
 
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.
Class Detail
Path(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} 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
 }
Method Detail
{Number} addNode(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

{Path} clone()
Create a clone of the path
Returns:
{Path} A new Path object

{SceneObject} debugDraw(toggle, layerId)
Create sprites to provide a visual representation of the path
Parameters:
{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.

{number} evaluate(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

<static> {SceneObject|null} Path.getDebugDrawObject()
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

{string} getName()
Get the name of the path
Returns:
{string}

{Object} 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.
Parameters:
{number} nodeIndex Optional
The index of the node. If omitted, the first node will be returned.
Returns:
{Object} A copy of the node data

{Object} 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.
Parameters:
{number} nodeIndex Optional
The index of the node. If omitted, the first node will be returned.
Returns:
{Object} The node data

{Array} getNodes()
Get a copy of the nodes array
Returns:
{Array} A copy of the nodes array

{boolean} isInScene()
Check whether the path is currently in the scene
Returns:
{boolean} Whether the path is currently in the scene

removeNode(nodeIndex)
Remove a node from the array of nodes
Parameters:
{number} nodeIndex Optional, Default: 0
The index of the node to remove

{object} 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.
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.

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.
Parameters:
{SceneObject} sceneObject
The SceneObject to use
{number} nodeIndex Optional, Default: 0
The index of the node that you want to modify

setName(name)
Set a name for this path
Parameters:
{string} name
The name to set

setNode(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):
 {
 	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.

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.
Parameters:
{Array} nodes
The array of nodes to use.

Documentation generated by JsDoc Toolkit 2.4.0 on Tue Jul 12 2016 07:54:40 GMT+0100 (BST)