The class MacaoObject in the package dynamic extends the MacaoObject of the package kernel with fields and methods for dynamic functionality. This includes walking, building nets, talking and others.
For more see the package description of dynamic.
Field Summary | |
---|---|
String | BUNCH_TYPE_SAY This is the quasi-constant defining the bunch type SAY. |
String | BUNCH_TYPE_STAND This is the quasi-constant defining the bunch type STAND. |
String | BUNCH_TYPE_WALK This is the quasi-constant defining the bunch type WALK. |
Method Summary | |
---|---|
void | accelerate(number acceleration)
Call this method to change the current velocity by the given value. |
void | addLookBunch(String bunchType, String imageBase, integer depth, String extension, integer baseWidth, integer baseHeight, optional integer deltaLeft, optional integer deltaTop, optional String phases)
Use this method to add a number of looks, which are building a bunch. |
MacaoTalkItem | addTalkItem(MacaoTalkItem talkItem)
Call this method to add a talk item to the object. |
void | adjustStacking()
Call this method to adjust the objects z-index according to the object's current position. |
void | approachAndTryAction(String targetObjectName, String eventName, optional String controllerName)
This method lets the object walk to a target object. When arrived, it lets the target object hear a trigger event, which may cause the execution of a talk item. |
boolean | approachObject(String objectName, optional boolean autoAcceleration, optional boolean stopAtEnd, optional String eventType, optional Array params)
Call this method to let the object walk near another object. |
boolean | approachPos(number xPos, number yPos, optional boolean autoAcceleration, optional boolean stopAtEnd, optional String eventType, optional Array params)
Call this method to let the object walk to a defined position. |
void | assignRoadNode(String roadName, integer nodeIndex)
Use this method to assign the object to a node, which is part of a road element. |
void | bindToNet(optional String netType)
Call this method to bind the object to a net or unbind it from a net. |
Array | calculateApproachPos(optional String approachingObjectName)
This method calculates the object's approach position, which is used by other objects to walk to. |
integer | calculateStackingIndex()
This method is called internally, to calculate the z-index for stacking. |
void | changeDirection(number angle)
Call this method to change the direction of the object by an angle. |
MacaoTalkItem | createTalkItem(String itemName, variant triggerEvents, optional String message, optional variant keywords, optional boolean onceAtTalk)
Call this method to create a talk item and add it to the object. |
number | getAnchorXPos()
Call this method to get the anchor's x-position of the object relative to the page. |
number | getAnchorYPos()
Call this method to get the anchor's y-position of the object relative to the page. |
boolean | getApproachable()
Call this method to get the info, if this object is approachable. |
MacaoNode | getAssignedNode()
Call this method to get the node, to which the object is assigned. |
String | getBunchPhase(String bunchType)
Call this method to get the phase, which is currently used to display a bunch look. |
Array | getDirection()
Call this method to get the direction, to which the object walks. |
Array | getLookDirection()
Call this method to get the direction of the look. |
number | getMaxVelocity()
Call this method to get the maximum velocity of the object. |
Array | getMeetingObjectNames()
Call this method to get an array with the names of all objects, which this object is currently meeting. |
MacaoNode | getNearestNode()
Call this method to get the nearest node of the net, to which the object is bound, relative to the objects current position. |
String | getNetType()
Call this method to get the net type of the net, to which the object is bound. |
String | getResponsesSenderName()
Call this method to get the name of the sender of the current response talk items. |
Array | getResponseTalkItems()
Call this method to get the response talk items, which are currently to be displayed for this object. |
boolean | getReverseGear()
Call this method to check, if the reverse gear is active. |
number | getVelocity()
Call this method to get the current velocity of the object. |
void | hearEvent(String eventName, optional String senderName)
Call this method to send the object a trigger event, which may cause the execution of a valid fitting talk item. |
void | hearFreeText(String freeText, optional String senderName, optional String responseItemName)
Call this method to send a keyword to the object, which may cause the execution of a valid fitting talk item. |
boolean | isMeetingObject(String objectName)
Call this method to test, if this object is currently meeting another object. |
boolean | isWalking()
Call this method to test, if the object is currently walking. |
void | leave(String objectName, optional boolean mutual)
Call this method to remove an object from the list of objects, which this object is currently meeting. |
boolean | mayILeaveNode(MacaoNode actualNode, MacaoNode toNode)
This method is called internally, before the object leaves a node. |
void | meet(String objectName, optional boolean mutual)
Call this method to add an object to the list of objects, which this object is currently meeting. |
void | moveAnchorTo(integer xPos, integer yPos)
Call this method to move the object giving the new coordinates for the anchor of the object. |
void | moveToNode(MacaoNode node, optional number directionX, optional number directionY, optional boolean noTriggerEvents)
Call this method to position the object on a node immediately. You can also set the direction of the object. |
void | onClickOther(Event event, integer mouseX, integer mouseY, String objectName)
This event handler is called, when the user clicks on another object. |
void | onClickWindow(Event. event, integer mouseX, integer mouseY, String frameName)
This event handler is called, when the user clicks the window. |
void | restore()
This method is called to restore the objects visibility, zoom, position, velocity, direction and walk target for this page, after the page is opened. |
void | setAnchorAtBottom(boolean activate)
Call this method to set the anchor to the bottom of the object. |
void | setApproachable(optional boolean approachable)
Call this method to set the object as approachable or not approachable. |
void | setApproachClick(boolean activate)
Call this method to activate or deactivate the behaviour of the object, which tells it to walk to the position where the user clicks. |
void | setAssignedNode(optional MacaoNode node)
Call this method, in order to assign or de-assign the object to a node. |
void | setAutoAcceleration(number autoAcceleration)
Call this method to set the acceleration of the object, for it's automatic acceleration. |
void | setAutoRestore(boolean autoRestore)
Use this method to activate or deactivate the automatic storage of the objects dynamic values, before the page is closed. |
void | setBunchDepth(String bunchType, integer depth)
Sets the maximum depth of a bunch type. |
void | setBunchPhase(String bunchType, optional String phase)
Call this method to set the current phase for a bunch type. |
void | setCollisionBreak(boolean activate)
Call this method to activate and deactivate collision break. |
void | setDirection(number dX, number dY)
Call this method to set the direction, to wich the object walks. This will also switch to the object to a look, which fits the direction. |
void | setDisableApproach(optional boolean activate)
Call this method to temporary disable the approach functionality of the object. |
void | setPreferredLook(String lookName)
Use this method, to set a look, which has precedence over all bunch looks. |
void | setRandomTalk(optional String eventName, optional integer baseDuration, optional boolean executeNow)
Call this method to start or stop the random execution of talk items, which are added to the object. |
void | setReverseGear(boolean activate)
Call this method, to activate or deactivate the reverse gear. |
void | setStacking(optional boolean active)
Call this method to activate or deactivate the stacking of the object. Stacking adjusts the objects z-index dependent on its position. |
void | setSteeringIndex(integer steeringIndex, optional boolean autoAcceleration, optional boolean stopAtEnd, optional String eventType, optional Array params, optional String controllerName)
Call this method to preselect the connection, which is to be used at the next node of a net and to start the walking of the object. |
void | setTalkCssClassName(optional String cssClassName)
Call this method to set a special cascading style sheet class, which will be used to display the bubble, when the object talks. |
void | setVelocity(number velocity)
Call this method to change the velocity of the object. |
void | setWalkCharacteristics(integer maxVelocity, optional integer maxAcceleration, optional number maxAngularVelocity, optional number curveBreak)
Call this method to set the walk characteristics of the object. |
void | setWalkPhases(String phases)
Call this method to set the phases, which are used to animate the object while it is walking. |
void | startAutoAcceleration()
Call this method to start the automatic acceleration of the object. |
void | steeredVelocityChanged(number velocity)
This event handler will be called, when this object is registered as a controller of another object and the velocity of the other object changes. |
void | stopWalking(boolean clearTarget, optional String controllerName)
Call this method to stop the walking of the object. |
void | store(optional boolean force)
This method is called to store the objects visibility, zoom, position, velocity, direction and walk target, before the page is left. |
void | tryAction(String targetObjectName, String eventName, optional String controllerName)
This method lets a target object hear an event. That event may cause the execution of a talk item. |
void | walkToNode(MacaoNode targetNode, optional boolean autoAcceleration, optional boolean stopAtEnd, optional String eventType, optional Array params)
Call this method to start the object walking along a net to a target node. |
void | walkToPos(integer xPos, integer yPos, optional boolean autoAcceleration, optional boolean stopAtEnd, optional String eventType, optional Array params, number endDirectionX, number endDirectionY)
Call this method to start the object to walk to given position on the page and to turn to a given direction. |
void | wanderAround(integer basePauseDuration, optional Array targetNodes)
Call this method to tell the object to wander around on a net. |
Field Details |
---|
This is the quasi-constant defining the bunch type SAY.
To use this constant call MacaoObject.prototype.BUNCH_TYPE_SAY.
See also addLookBunch().
This is the quasi-constant defining the bunch type STAND.
To use this constant call MacaoObject.prototype.BUNCH_TYPE_STAND.
See also addLookBunch().
This is the quasi-constant defining the bunch type WALK.
To use this constant call MacaoObject.prototype.BUNCH_TYPE_WALK.
See also addLookBunch().
Method Details |
---|
Call this method to change the current velocity by the given value.
The velocity is automatically limited between zero and the maximum velocity defined for the object.
See also setVelocity() and setWalkCharacteristics().
Use this method to add a number of looks, which are building a bunch.
HTML is not able to rotate an image to show e.g. a car driving in different directions. Instead you have to add a number of images, showing the car in several directions. The images have to be added as MacaoLook objects. Such a set of images I call a bunch.
One call to the method addLookBunch() creates and adds such a set of looks to the object. A bunch has a special naming convention for the look names. When you use this method, you also have to follow the naming convention for the filenames of the images. The name of a look in the bunch consists of the bunch type and a binary like string encoding the direction.
The bunch type defines the purpose, for which the look is displayed. There are three bunch types. They are defined as constant properties
of the class: BUNCH_TYPE_STAND, BUNCH_TYPE_SAY and BUNCH_TYPE_WALK. The constants contain the strings "Stand", "Say" and "Walk".
A look of a bunch type Walk is displayed, when the velocity of the object is not zero (see also setVelocity(), walkToPos() and setApproachClick()). If the objekt is not walking or there is no look of the type Walk, a look of the type Say or Stand is displayed. A look
of the bunch type Say is displayed, while a bubble is displayed for the object (see also say() and addTalkItem()). If there is no look of type Say, then there is a look of type Stand displayed. The look will automatically be adjusted,
when you use the functionality of the package dynamic.
The direction is encoded by a binary like string consisting of the characters "0" and "1". North is the "0". South is the "1". East is the "01" and west is the "11". Each subdivision of the directions extends the number by a digit. This has the advantage, that each direction keeps its name, even if you increase or reduce the number of subdivisions. You only need to change the depth, not the names of the files.
Here is a list of the encoding for a depth of 5 (=32 directions) in clock wise order:
0 (= north), 00001, 0001, 00011, 001, 00101, 0011, 00111,
01 (= east), 01001, 0101, 01011, 011, 01101, 0111, 01111,
1 (= south), 10001, 1001, 10011, 101, 10101, 1011, 10111,
11 (= west), 11001, 1101, 11011, 111, 11101, 1111, 11111
See the tutorial for a better presentation.
The depth defines the number of directions, which is the number of images for a bunch. A bunch has 2 to the power of depth directions. For example, a bunch of depth 3 has 8 looks, which are 8 images. If you call the method addLookBunch() with a depth of 3, all the 8 looks will be created and added.
The images, which are added using the method addLookBunch() must also follow the naming conventions. For Example:
myObject.addLookBunch(myObject.BUNCH_TYPE_STAND, "optional/cars/blue/carBlue", 1, ".gif", 20, 20)
The example adds two looks to the object, because 2 to the power of 1 is 2. The first look has the name "Stand0" and its image has the URL "optional/cars/blue/carBlueStand0.gif". It shows the car looking north. The second look has the name "Stand1" and its image has the URL "optional/cars/blue/carBlueStand1.gif". It shows the car looking south. If you want more directions, just increase the depth. Set the depth to 5 to load looks for 32 directions. Of course 32 images need to be there.
You can use phases, to define the animation of walking objects like characters or to switch between bunches. The use of phases is optional.
To animate a character, you use for example three different images for each direction. You may call the phases a, b and c. First you have to create three images for each direction. You have to insert the name of the phase between the direction part and the extension of the filename of the images. So the images for the direction north may have the filenames arnoldWalk1a.gif, arnoldWalk1b.gif, and arnoldWalk1c.gif. To add a bunch containing all the phases, you provide the parameter phases like in the following example.
myObject.addLookBunch(myObject.BUNCH_TYPE_WALK, "optional/characters/arnold/arnold", 1, ".gif", 20, 20, 0, 0, "a,b,c")
Now you have to use the method setWalkPhases() to tell the object the sequence of phases, which is used to animate the object during walking. In the example the image b has to be used twice in the animation. So you get the sequence a-b-c-b-a-b- and so on. Each phase-image in the sequence is displayed for the duration of a walk interval (see MacaoPage.setWalkInterval()). The walk interval is by default 150ms plus the time the computer needs to calculate the next step and to repaint the object. You can display a phase-image for a longer time by repeating the name of the phase in the sequence. A typical walking sequence can be defined like this:
myObject.setWalkPhases("a,b,c,b")
The other purpose of phases is to have loaded several bunches for the same bunch type and switch between the bunches. For example you want to display a dumper in loaded and in unloaded state. First you have to create the images for all states and all directions. Again the name of the phase has to be inserted after the direction part and before the extension of the filenames. You can use one call of the method addLookBunch() to add both phases.
myObject.addLookBunch(myObject.BUNCH_TYPE_STAND, "optional/cars/dumper/dumper", 1, ".gif", 20, 20, 0, 0, "loaded,unloaded")
Then you can use the method setBunchPhase() to switch between the phases, when the dumper is loaded or unloaded.
myObject.setBunchPhase(myObject.BUNCH_TYPE_STAND, "loaded")
You can mix up both techniques. So you can display a character, which for example is carrying a book or carrying nothing. Use the method setWalkPhases() to switch between the phases.
To add a bunch of looks with your own images, you first need to crate the bunch images. There is the tool rotate.hta respective rotate.html contained in the distribution of Macao. It helps you to rotate images, which are showing objects in the birds view.
Rotate is using the freeware toolset Image Magick to rotate the images. You need to download Image Magick from the web (www.imagemagick.org) and install it on your computer. You should also download Image Magicks separate library for gif compression.
If you are on a MS Windows system (others see below), start rotate.hta. It is an HTML-application and runs on windows systems without installation. The application consists of a handful of little HTML- and Java Script files. When you start the application, it offers a dialog like window. Fill out the fields: Select the location of the convert.exe file of the Image Magick installation. Select the source image, which you want to rotate. Enter the size of the source image.
The source image has to be of square format. It may be much larger than the resulting bunch images. It has to show the object in the direction north (= up). It's recommended to use a gif image with transparent background. You need to know the transparent colour. Enter the colour like using the pattern of the example, which is displayed by default. The object, which is shown in the image, should be a little smaller than the image, because when it is rotated, the corners will be cut.
Enter the path, where the bunch images are to be created. Add the beginning of the filename to the path. Select the bunch type. Enter the file extension. Enter the width of the image. Select the bunch depth. That sets the number of images for the full rotation. Click "Rotate" to start the generation of the images. The created images will automatically appear in the preview. The DOS commands, which are used to create the images, are shown in the field "Generated Shell Commands".
When you are not on MS Windows, you can't start rotate.hta, because it is M$ specific. But you can open the web page rotate.html with the browser. Fill out the fields as described above. Click "Rotate", to generate the shell commands. Copy the shell commands to the clipboard and paste them to a shell script file. Execute the shell script file, to generate the images.
Call this method to add a talk item to the object.
See the description of the class MacaoTalkItem for a detailed description on how to use talk items.
Call this method to adjust the objects z-index according to the object's current position.
If staggering is set active for the object (see setStaggering()), the method calls calculateStaggeringIndex(), to get the fitting z-index for the object's current position, and sets it to the object. See also setZIndex().
This method lets the object walk to a target object. When arrived, it lets the target object hear a trigger event, which may cause the execution of a talk item.
This method uses the method approachObject() to walk to the target object. You may use the method addTalkItem() to add a talk item to the target object, which reacts to the given event name.
Controllers primarily use this method.
Call this method to let the object walk near another object.
If the target object is assigned to a node, the position of the node is used as the target position (see setAssignedNode()). If the target object is not assigned to a node, the target position is calculated by the method caclulateApproachPos() of the target object.
If the object is bound to a net, the object walks along the net to the node, which is next to the position. If the object is not bound to a net, the object walks to the position. See also bindToNet() and MacaoNet. See also approachObject().
Call this method to let the object walk to a defined position.
If the object is bound to a net, the object walks along the net to that node, which is next to the position. If the object is not bound to a net, the object walks to the provided position. See also bindToNet() and MacaoNet. See also approachObject().
Use this method to assign the object to a node, which is part of a road element.
This method does the same as setAssignedNode(), but it gets the node for the assignment by the name of the road element and the index of its node.
Call this method to bind the object to a net or unbind it from a net.
An object can only be bound to one net at a time. See also MacaoNet.
This method calculates the object's approach position, which is used by other objects to walk to.
By default the method calculates a position, which is in the centre of the objects width and below the bottom of the object. The distance below the object is dependent of the object that wants to approach. If the approaching object is available, the position will be 1/3 of the height of the approaching object below the approached object. If the approaching object is not available, the distance is calculated by the approached object's height.
You may override this method, to calculate another approach position. The following example calculates a position in the centre of the object.
// create object var house = new MacaoObject("house", "House", 200, 200) house.setImage("house.gif") // override method house.calculateApproachPos = new function(approachingObjectName) { // create array with coordinates return new Array( (this.getLeft() + this.getWidth()) / 2, (this.getTop() + this.getHeight()) / 2 ) }
See also setApprochable().
This method is called internally, to calculate the z-index for stacking.
By default, this method returns the y-coordinate of the bottom edge of the object. You may override this method, if you want another value to be used for stacking. See also setStacking().
Call this method to change the direction of the object by an angle.
See also setDirection() and getDirection().
Call this method to create a talk item and add it to the object.
This method is provided for convenience, because it creates and adds a talk item in one call. The method returns the talk item, which is created. So you can use the returned item to specify further properties of the talk item. See the description of the class MacaoTalkItem for a detailed description on how to use talk items.
Call this method to get the anchor's x-position of the object relative to the page.
This method calculates the anchor position of the object. By default that position is in the centre of the object. The anchor is used to walk the object along a net or to a click. For Example, if the object is not bound to a net but has the property approach click activated, and the user clicks on the page, the object will walk to the click position, so that its anchor (centre) is placed on the click position. See also getAnchorYPos().
If you want another position for the anchor of your object, you need to call setAnchorAtBottom() or override the methods getAnchorXPos() and/or getAnchorYPos(). You can use the methods getLeft(), getTop(), getWidth() and getHeight() to calculate your own anchor position. The following example overrides the method getAnchorYPos(), to place the anchor at the bottom of the object.
var car = new MacaoObject("Car", "Car", 200, 200) car.getAnchorYPos = function() { return this.getTop() + this.getHeight() }
Call this method to get the anchor's y-position of the object relative to the page.
See also getAnchorXPos() and setAnchorAtBottom().
Call this method to get the info, if this object is approachable.
See also setApproachable().
Call this method to get the node, to which the object is assigned.
See also setAssignedNode().
Call this method to get the phase, which is currently used to display a bunch look.
See addLookBunch() for a description of phases.
Call this method to get the direction, to which the object walks.
See also getLookDirection(), setDirection(), setReverseGear() and changeDirection().
Call this method to get the direction of the look.
If the reverse gear is not active, this method returns the same direction as the method getDirection(). If the reverse gear is active, this method returns the opposite direction. See also setReverseGear() and addLookBunch().
Call this method to get the maximum velocity of the object.
See also setWalkCharacteristics().
Call this method to get an array with the names of all objects, which this object is currently meeting.
See also meet(), leave() and isMeetingObject().
Call this method to get the nearest node of the net, to which the object is bound, relative to the objects current position.
To get a node, the object needs to be bound to a net. See also MacaoNet and bindToNet().
This method is used internally, when the object starts to walk along a net. It is used to find the start node of the walk. The object will walk to the nearest node and than along the net to a target node.
Call this method to get the net type of the net, to which the object is bound.
See also MacaoNet.
Call this method to get the name of the sender of the current response talk items.
Call this method to get the response talk items, which are currently to be displayed for this object.
See also hearResponseTalkItems().
Call this method to check, if the reverse gear is active.
See also setReverseGear().
Call this method to get the current velocity of the object.
See also getVelocity().
Call this method to send the object a trigger event, which may cause the execution of a valid fitting talk item.
If the object has one or more valid talk items, which are fitting to the trigger event, one of them will be executed. The validity of a talk item may be restricted by game events or by the property onceAtTalk. This method is called internally for every event, which the object receives. See also MacaoTalkItem and hearFreeText().
Call this method to send a keyword to the object, which may cause the execution of a valid fitting talk item.
If the object has one or more valid talk items, which are fitting the keyword, one of them will be executed. The validity of a talk item may be restricted by game events or by the property onceAtTalk. This method is called internally to provide the input text, which was entered by the user in a response talk item, which was originated by this object. See also MacaoTalkItem and hearEvent().
You may use this method to trigger the execution of a talk item, even if this free text was not caused by a response talk item.
Call this method to test, if this object is currently meeting another object.
See also meet(), leave(), getMeetingObjectNames() and isMeetingObject().
Call this method to test, if the object is currently walking.
Call this method to remove an object from the list of objects, which this object is currently meeting.
See also meet(), getMeetingObjectNames() and isMeetingObject().
This method is called internally, before the object leaves a node.
This functionally is used for example, to determine, if a traffic light prevents the continuation of the walking. Actually this method forwards the request to the method mayILeave() of the actual node.
You may override this method to change the objects behaviour.
Call this method to add an object to the list of objects, which this object is currently meeting.
One object can for example meet another object, when it enters a node, which is assigned to the other object (see setAssignedNode()). You can restrict talk items to send trigger events only to nodes, which the object is currently meeting (see MacaoTalkItem.setBroadcast()). See also leave(), getMeetingObjectNames() and isMeetingObject().
Call this method to move the object giving the new coordinates for the anchor of the object.
While calling moveTo() sets the new left and top coordinates of the object, moveAnchorTo() sets the new anchor position of the object. By default, the anchor position is in the centre of the object. You can set it to the center of the bottom calling setAnchorAtBottom(). See also getAnchorXPos().
Call this method to position the object on a node immediately. You can also set the direction of the object.
This method also sets the provided node as the actual node. This sends the trigger event enteringNode_NodeName and eventually the leavingNode_NodeName to the object. The trigger events may trigger talk items. You can prevent the events by setting the parameter noTriggerEvents. See also MacaoTalkItem.
For positioning the object the object's anchor position is used. See getAnchorXPos(). This method is useful to place an object on a node, after the page is loaded. See also MacaoNet and getNodeByName().
This event handler is called, when the user clicks on another object.
The default implementation of this event handler checks, if the property "approach click" is activated (see setApproachClick(), and initiates the walking of the object to the clicked object.
You may override this event handler to implement another functionality.
This event handler is called, when the user clicks the window.
The default implementation of this event handler checks, if the property "approach click" is activated (see setApproachClick(), and initiates the walking of the object to the clicked position.
You may override this event handler to implement another functionality.
This method is called to restore the objects visibility, zoom, position, velocity, direction and walk target for this page, after the page is opened.
These values need to be stored before by the method store().
Call this method to set the anchor to the bottom of the object.
By default the anchor is at the center of the object. See also getAnchorYPos() and moveAnchorTo().
Call this method to set the object as approachable or not approachable.
When an object is set as approachable and the user clicks on the object, other objects which have the property approach click activated (see setApproachClick()) will start walking to the clicked object's approach position. If the object is not set as approachable and the user clicks on the object, the other objects will walk to the position of the click. So the difference is in the target position, to which the objects will walk.
If the object is assigned to the node of a net, the node position is the object's approach position. Otherwise the approach position of an object is calculated by its method calculateApprochPos().
Set this property for foreground objects. Don't set this property for background objects. Because clicking on the background should tell the walking objects: Walk to the click position.
Call this method to activate or deactivate the behaviour of the object, which tells it to walk to the position where the user clicks.
If the object is bound to a net, the object will walk along the net to that node, which is next to the clicked position. If the object is not bound to a net, the object will walk to the clicked position. See also bindToNet() and MacaoNet.
When the user clicks on a target object, the position to which this object walks depends on the target object's properties
and methods. If the target object is not set as approachable (See setApproachable()), this object walks to the clicked position.
If the target object is set as approachable and it is assigned to a node (see setAssignedNode()), this object walks to the position of the node. If the target object is not assigned to a node, the target position is calculated
by the target objects method calculateApproachPos().
Call this method, in order to assign or de-assign the object to a node.
If the object is assigned to a node and the user clicks on the object, all objects that have the property approach to click (See setApporachClick()) activated and which are bound to the net of the node, will walk to the specified node. When the walking object reaches the
node, the object will "hear" the event, which is telling that the walking object meets it (See hearEvent()). It may respond with executing a talk item. See addTalkItem().
If the object, on which the user clicks, is not assigned to a node, the walking object approaches the clicked object. But
it is walking to a node near the click coordinates and not to a specific node. The clicked object will hear no event about
that the walking object has arrived.
An object can only be assigned to one node at a time. See also getNodeByName().
Call this method to set the acceleration of the object, for it's automatic acceleration.
To start the automatic acceleration, you have to call the method startAutoAcceleration() or setApproachClick().
Use this method to activate or deactivate the automatic storage of the objects dynamic values, before the page is closed.
The values will be restored, when the page is loaded again. See also store() and restore().
Sets the maximum depth of a bunch type.
Use this method, if you are defining a bunch by adding looks one by one. You don't have to add all looks for a bunch. For
example, you can have only three images for a bunch. So you can't call addLookBunch(), because it defines two to the power of n looks. But you can add each look using the method createLook(), providing the right bunch look name. But in this case you have to set the depth of the bunch. The object uses the depth
to find a fitting look for a direction. In the case you added three looks, this would be 2, because 2 to the power of 2 is
greater equal 3.
If you use addLookBunch(), the depth is set automatically.
Call this method to set the current phase for a bunch type.
See addLookBunch() for a description of phases.
Call this method to activate and deactivate collision break.
If you activate collision break, the object will stop immediately, when it approaches from behind too near to another object, which also has collision break switched on. The collision break does not work, when the two objects are approaching frontal, because this would cause a dead lock.
Activate collision break for cars. The default value is off.
Call this method to set the direction, to wich the object walks. This will also switch to the object to a look, which fits the direction.
The parameters are building a vector. When set, the components of the vector are automatically recalculated to build a vector
of the length of 1.0.
One of the parameters must not be zero. Otherwise the direction of the object will not be changed.
See also setReverseGear(), getDirection(), getLookDirection() and changeDirection().
Call this method to temporary disable the approach functionality of the object.
This is useful, when for example a character has to stay sitting on a chair while it tries actions. The actions, which are sent by the sentence controller, will be tried from remote, while the object stays in its place.
Use this method, to set a look, which has precedence over all bunch looks.
Use the method, if you have added bunch looks to the object, but you temporary want to display a specific look. If you set the preferred look, it will be displayed, even if there are fitting bunch looks. Use this method to set and clear the preferred look. Keep in mind, that you first have to add the look using the method createLook().
If you want to display a specific look, while the object is saying something, you better use the method MacaoTalkItem.setLookName().
Call this method to start or stop the random execution of talk items, which are added to the object.
The talk items, which are executed randomly, have to be added to the object using the methods addTalkItem() or createTalkItem(). They also must have an equal trigger event. You must provide this event name as parameter. There can only be one random execution of talk items at a time. So when you call this method again to set another event name, the prior random execution will be stopped. Call this method without event name to stop the execution of random talk events. See also MacaoTalkItem.
Call this method, to activate or deactivate the reverse gear.
When the reverse gear is active, the object walks in the opposite direction of its look. But it still only walks in the direction of the connections of a net. So you can't use the reverse gear to walk against a one way. See also getDirection(), getLookDirection() and getReverseGear().
Call this method to activate or deactivate the stacking of the object. Stacking adjusts the objects z-index dependent on its position.
When your page shows the objects in a side view rather than in a birds view, it is necessary to adjust their z-index to show their layers in the correct order. A layer with a larger z-index shows the object more on top of the stack of layers. A layer with a lower z-index appears more in the background and may be buried partially or completely by other objects.
Stacking automatically adjusts an object's z-index dependent on its position. By default, it sets the object's z-index to
the y-coordinate of the object's bottom edge. So objects, which are more at the bottom of the page, are appearing in front
of objects, which are more at the top of the page. When for example a character walks around a table, it appears in front
of the table, when the characters feet appear lower then the table-legs. It appears behind the table, when its feet are higher
than the table's legs.
Hint: You should build the MacaoNet for the character so, that it walks around the table but not through the table.
All you have to do is to activate the stacking for the objects, which are walking or which can be walked around. Don't activate stacking for background objects like the road grid. By default, the objects z-index is adjusted, when the object is moved. You can force the adjustment by calling adjustStacking(). You can change the calculation of the z-index by override calculateStackingIndex(). See also setZIndex().
Call this method to preselect the connection, which is to be used at the next node of a net and to start the walking of the object.
Steering is a special way to control the walking of an object through a net. Steering means to preselect the connection, which the object will choose at the next node to continue its walking. This preselection works with an index, which can be 0, positive or negative. 0 tells the object to select the most straight ahead connection in the view of the object. An index of -1 means the next connection to the left of the straight-ahead one. An index of 1 means the next right one, and so on. Normally indexes between -2 and 2 are useful.
The index will be maintained across the nodes. For example, if you set the index to -2 and there is only one connection to the left of the most straight ahead connection, the object will use this connection and will change the index to -1. At the following node the index of -1 will cause the object to select one connection to the left, if there is one. If there is such connection, the index will change to 0. Now with an index of 0 the object will walk through the net, ever taking the most straight ahead connection. Of course you can call this method at any time to change the index again.
The call of the method setSteeringIndex() will only initiate the walk to the node after the next node. To get a continuous walking, you have to use or to implement a steering controller. A controller is an object, which is registered as a controller to this object by calling addController(). Every controller will receive the event (= method call) steeredEnteringNode(steeringIndex), when the object is entering the next node. The steering controller has to respond to this call by sending the next setSteeringIndex event, to set the path for the following node. This ping-pong play between the object and its steering controller makes it possible to the steering controller to display a steering wheel, which reflects the current value of the steering index. The class MacaoSteeringController is an implementation of a steering controller, which you can use. Every registered controller will also get the event steeredVelocityChanged(), when the velocity of the object changes.
A steering controller can use the following methods to control the object: Call setSteeringIndex() to adjust the steering index and to start the walking. Call getSteeringIndex() to get the actual steering index. Call stopWalking() to stop the objects walking. See also MacaoNet.
Call this method to set a special cascading style sheet class, which will be used to display the bubble, when the object talks.
Call this method to change the velocity of the object.
To accelerate a car, you should better call startAutoAcceleration(). See also getVelocity(), accelerate() and setWalkCharacteristics().
This value is set in pixels per step. But this is only true for the default step duration. If you change the step duration
(setMoveInterval()) the value is automatically recalculated where used. When the object is zoomed, the velocity is also recalculated when used.
So smaller zoomed objects automatically move slower than larger objects.
The velocity is automatically limited between zero and the maximum velocity defined for the object.
Call this method to set the walk characteristics of the object.
For example increase the maximum velocity and the maximum acceleration for larger objects.
Some values are set in pixels per step. But this is only true for the default step duration. If you change the step duration (setMoveInterval()) the values are automatically recalculated where used.
Call this method to set the phases, which are used to animate the object while it is walking.
See addLookBunch() for a description of phases.
Call this method to start the automatic acceleration of the object.
The object will accelerate, until it reaches its maximum velocity. See also setWalkCharacteristics() and setAutoAcceleration().
This event handler will be called, when this object is registered as a controller of another object and the velocity of the other object changes.
You can implement this event handler, to display the velocity of an object. See also addController(). There is no default implementation of this event handler.
Call this method to stop the walking of the object.
See also walkToPos(), walkToNode(), wanderAround() and MacaoNet.
This method is called to store the objects visibility, zoom, position, velocity, direction and walk target, before the page is left.
The values are stored, if the property auto restore is set or if the parameter force is set to true. The method stores the values using the storage manager. See also setAutoRestore(), restore() and the class MacaoPage in the package storageManager.
This method lets a target object hear an event. That event may cause the execution of a talk item.
You may use the method addTalkItem(), to add a talk item to the target object, which reacts to the given event name.
Controllers primarily use this method.
Call this method to start the object walking along a net to a target node.
The object needs to be bound to a net and the target node needs to be part of that net. The start node also needs to be connected to the target node via the net. The start node is the actual node, or the next node from the last walk or the nearest node, if the others are not defined. See also MacaoNet and getNearestNode().
Call stopWalking() to stop the object before reaching the target node. You can also define another walk target before it reaches the target node. See also walkToPos().
Call this method to start the object to walk to given position on the page and to turn to a given direction.
If you call this method, the object is walking independent from a net, even if it is bound to a net. See also MacaoNet and bindToNet().
Call stopWalking() to stop the object before it reaches the target position. You can also define another walk target. See also walkToNode().
Call this method to tell the object to wander around on a net.
The object needs to be bound to a net. See also MacaoNet and bindToNet().
Call stopWalking() to stop the object wander around. You can also stop it wandering around by setting another walk target. See walkToPos() and walkToNode().