Package dynamic

The dynamic package is implemented in the file core/dynamic.js. A compressed version of the package is available in the file core/compressed/dynamic.js. The package is needed in every main content page. It is not needed in controllers- and inventory pages. Load this package after the kernel.js package.

Load the package in a page, to extend the class MacaoObject by properties and methods for dynamic functionality, like walking and talking.

Walking

Walking means to let the object move step by step over the page. Walking is also used to let a car drive through a road map or to let a character walk through a room.

As basis for walking you should build a net. A net consists of nodes (MacaoNode), which are connected by connections (MacaoConnection). See MacaoNet on how to build a net. When you have built a net, you create an object, like a car or a character, which has to walk on the net. Bind the object to the net using the method bindToNet(). You can activate the functionality of the object to walk to the position where the user clicks by calling setApproachClick(). Or you can call walkToNode() to let the object walk to a specified node in your net. With the method wanderAround() you can let your object wander around randomly in your net.

You have also the option to use no net but let the objects walk free across the page. Use the method setApproachClick() to enable the object for user interaction or call walkToPos() to control it by your program.

Another way to steer your object is to control it via direction and velocity rather than by position or net. Use the methods setDirection(), changeDirection() setVelocity(), accelerate() and startAutoAcceleration().

A special way to control the walking of an object trough a net is steering. Steering means to pre-select the connection at the next node, which the object will pass, by setting a steering index. There is a steering controller, which can be used to steer a car using this technique. Call setSteeringIndex() to control the steering of the object by your program. Or include the MacaoSteeringController in your application, to let the user steer the object through the net.

While a net defines paths for the objects but is invisible to the user, you can build a road map using the package core/road.js. With this package you can use the Road Editor to build a complex roadmap. Such a roadmap consists of a net for the objects to walk on and a road grid, which displays the road on the page.

You can resize the walking objects dependent on their position in the net by setting the zoom property of the nodes in the net. See MacaoNode.setZoom().

To let an object show different looks (images) when walking in different directions, you can add look bunches to the object. See addLookBunch(). For objects, which are to be shown in birds view, there is the tool Rotate to create the rotated images of the object.

For a more 3-D like view of objects you can control how the layers of the objects are stacked. You just have to activate stacking for the objects, which are not foreground or background. When the objects are changing their position on the page, the layers will be adjusted automatically. See setStacking().

The characteristics for walking can be changed by the method setWalkCharacteristics(), setAutoAcceleration() and setCollisionBreak().

Talking

Talking means to predefine actions, which are executed in response to events. An action can display a bubble or raise any type of event. See MacaoTalkItem for a description on how to use talk items.

Class Summary
MacaoPage

The class MacaoPage is not a class itself, but it is used to document the global properties and methods of the package core/dynamic.js.

MacaoObject

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.

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.

MacaoConnection

This class is used internally to represent the connection between two MacaoNode objects in a MacaoNet.

MacaoNode

This class is used to build a node in a MacaoNet.

MacaoTalkItem

Use the class MacaoTalkItem to create talk items and add them to MacaoObjects.