-
Notifications
You must be signed in to change notification settings - Fork 111
Path Guide
The "Path" is a series of nodes, like a track or a series of way points that an object can attach to. The SceneObject will then move from node to node along the path. There are a number of ways to customize this behavior.
The Path object has a very short list of methods that are used to control it.
You will always want to call this method at least twice after creating a Path object. This method creates a node at a world point. The node is immovable once created and is simply the location that objects attached to the path will go to. The x and y coordinates are the location of the node. The distance variable will determine how close an object has to get to the node before it is considered to have arrived at the node. If you imagine the object as a series of circles, the distance would be similar to the radius of each circle. Once an object enters the circle, it has arrived at the node and will begin toward the next node.
attachObject(SceneObject object, float speed, float force, bool orient, float angOff, bool snapToNode, int startNode, bool loop, int maxLoop)
Once you've created a path you just need to call this function to add a SceneObject to it. There are a large number of ways to customize what the SceneObject does once it's attached to the path.
- object This is the SceneObject that you want to follow the path.
- speed This is the maximum speed that the object will move when following the path.
- force This is the optional force that will be applied to the object when moving along the path. If not supplied this will be set to 3. The force will be constantly applied to the object. A stronger force will make the object follow the path in a more rigid way. A weaker force will allow the object to be hit off the path and turn corners in a more natural way.
- orient If true, the object will be rotated to face the direction that it is moving. Defaults to false.
- angOff This is the optional rotation offset that will be applied to the object if orient is true. If a sprite's image is facing straight up then the angle offset should be zero.
- snapToNode If true, the object will be relocated to its starting node when it's attached to the path.
- startNode A zero-based index of the starting node. Defaults to zero which is the first node.
- loop If true, the object will start the path again when it reaches the last node. The object will travel from the last node to the first.
- maxLoop The number of times that the object will travel the path if looping is on.
This simply removes the object from the path.