API Documentation for: 0.11.8
Show:

platypus.components.NodeMap Class

This component sets up a NodeMap to be used by the NodeResident component on this entity's child entities.

Methods

'add-node'

(
  • definition
)

Defined in 'add-node':140

Expects a node definition to create a node in the NodeMap.

Parameters:

  • definition Object

    Key/value pairs.

    • nodeId String | Array

      This value becomes the id of the Node. Arrays are joined using "|" to create the id string.

    • type String

      This determines the type of the node.

    • x String

      Sets the x axis position of the node.

    • y String

      Sets the y axis position of the node.

    • z String

      Sets the z axis position of the node.

    • neighbors Object

      A list of key/value pairs where the keys are directions from the node and values are node ids. For example: {"west": "node12"}.

'child-entity-added'

(
  • entity
)

Checks the child entity for a nodeId and if found adds the child to the corresponding node.

Parameters:

  • entity platypus.Entity

    The entity that may be placed on a node, or if the entity is a node it is added to the map of nodes.

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.

getNode

(
  • id
)

Defined in getNode:218

Gets a node by node id.

Parameters:

  • id String | Array | Node

    This id of the node to retrieve. If an array or more than one parameter is supplied, values are concatenated with "|" to create a single string id. Supplying a node returns the same node (useful for processing a mixed list of nodes and node ids).

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

map

Array

Defined in map:98

An array of node definitions to create the NodeMap. A node definition can take the following form:

    {
                                                  "NodeId": "Node1",
                                                  // A string or array that becomes the id of the Node. Arrays are joined using "|" to create the id string.
                                                  "type": "path",
                                                  // A string that determines the type of the node.
                                                  "x": 0,
                                                  // Sets the x axis position of the node.
                                                  "y": 0,
                                                  // Sets the y axis position of the node.
                                                  "z": 0,
                                                  // Sets the z axis position of the node.
                                                  "neighbors": {
                                                  // A list of key/value pairs where the keys are directions from the node and values are node ids.
                                                    "west": "node0",
                                                    "east": "node2"
                                                  }
                                                }

Default: []