This class is used to build a node in a MacaoNet.
You can build a MacaoNet to have paths for your objects to walk on. A MacaoNet is identified by its name (= net type). See getNet(). A MacaoNet is build of MacaoNode objects, which are connected by MacaoConnection objects.
You create a net just by creating a node for this net. You provide the net
For nets that are representing a room for example, you will build the net "manual", by adding nodes and connecting them. For road maps, there is the package core/road.js. You can use this package to build large road maps. There you can use the Road Editor to build a large net, just by using the mouse. This functionality is using MacaoNet, MacaoNode and MacaoConnection to build a net with the name (= net type) "Road". You can use this net like a net you built manually.
Constructor Summary |
---|
MacaoNode(String netType, integer xPos, integer yPos, optional MacaoObject ownerObject, optional String name)
Use this constructor to create a new node in a net. |
Method Summary | |
---|---|
number | calculateDistanceTo(integer xPos, integer yPos)
Call this method to calculate the distance from this node to another position. |
MacaoConnection | connectTo(MacaoNode node, optional boolean alsoBack)
Call this method to connect this node to another node by a MacaoConnection. |
void | disconnectFrom(MacaoNode node, optional boolean alsoBack)
Call this method to remove the connection from this node to another node. |
Array | getAssignedObjectNames()
Call this method to get an array with the names of all the objects, which are assigned to the node. |
Array | getConnections()
Call this method to get an array containing all the connections from this node. |
integer | getIndex()
Call this method to get the index of the node in the MacaoNet the node belongs to. |
String | getName()
Call this method to get the name of the node. |
String | getNetType()
Call this method to get the name of the net the node belongs to. |
boolean | getStepOn()
Call this method to check, if the property stepOn is activated. |
integer | getXPos()
Call this method to get the x-coordinate of the node. |
integer | getYPos()
Call this method to get the x-coordinate of the node. |
number | getZoom()
Call this method to get the zoom factor, which is used to scale objects, which are passing this node. |
boolean | mayILeave(MacaoObject object, MacaoNode toNode)
This method is called, when an object wants to leave the node. The method can prohibit the leaving if it is for example controlled by a traffic light. |
void | setName(optional String nodeName)
Call this method to name the node. |
void | setStepOn(boolean activate)
Call this method to define if walking objects have to step on this node. |
void | setZoom(number zoomFactor)
Call this method to set a zoom factor, which will be used to zoom objects, which walk over this node. |
Constructor Details |
---|
Use this constructor to create a new node in a net.
When you create a node, the node is automatically registered to the net that is defined by the parameter netType. See also MacaoNet.
Method Details |
---|
Call this method to calculate the distance from this node to another position.
Call this method to connect this node to another node by a MacaoConnection.
See also disconnectFrom().
Call this method to remove the connection from this node to another node.
See also connectTo().
Call this method to get an array with the names of all the objects, which are assigned to the node.
See MacaoObject.setAssignedNode().
Call this method to get an array containing all the connections from this node.
See also connectTo().
Call this method to get the index of the node in the MacaoNet the node belongs to.
See also MacaoNet.getNodeByIndex().
Call this method to get the name of the node.
See also setName().
Call this method to get the name of the net the node belongs to.
See also MacaoNet.
Call this method to check, if the property stepOn is activated.
See also setStepOn().
Call this method to get the x-coordinate of the node.
Call this method to get the x-coordinate of the node.
Call this method to get the zoom factor, which is used to scale objects, which are passing this node.
See also setZoom().
This method is called, when an object wants to leave the node. The method can prohibit the leaving if it is for example controlled by a traffic light.
If an owner object has been assigned to the node (see MacaoNode()) the request to leave is forwarded to the owner. At the owner object the method mayObjectLeaveNode(object, fromNode, toNode) is called, where object is the object that wants to leave, fromNode is this node and toNode is the next node the object wants to walk to. The parameter toNode may be null.
Call this method to name the node.
You can use MacaoPage.getNodeByName() to find a node by its name. See also getName().
Call this method to define if walking objects have to step on this node.
If the property step on is deactivated, walking objects may step over this node in the direction to the next node. This makes the walking smoother. Set this property to true, if the node is for example a traffic light the object has to step on or if the node is assigned to an object. So when the walking object is walking to the assigned object it will stop exactly on the node. For traffic lights and assigned objects this property is set automatically. So you may set it for your own purposes. By default this property is set to false.
Call this method to set a zoom factor, which will be used to zoom objects, which walk over this node.
If an object steps on this node, the zoom factor is set to the object. If the object walks on a connection between this node and another node, the zoom factor of the object will be set to a value calculated of the zoom factors of both nodes. The default value of the zoom factor is 1.0. See also MacaoObject.setZoom().