I just uploaded an update to the Wander motion class I released a couple weeks ago.
This version has some new features that I’ve added as I needed them, like:
- targetObject: set the Wander to use the x/y of another display object as it’s target x/y. There are lots of possibilities with this: you can follow another wandering sprite, follow a sprite moving in a completely different way (ex. a bouncing ball), or even follow a sprite that was tweened in the timeline or via a tweening library.
- rotationLimit: sets a limit on the maximum amount that the rotation can change in a single update of the wander. You can use this to get nice smooth arcs and more gradual responses (particularly when using targetObject).
- update(): you can set autoUpdate (which replaces paused) to false, and call update directly if you have a central tick dispatcher.
- getShortRotation(): exposed this helper method for general use.
- always operates on the target’s current rotation. Now you can change the rotation between updates, and Wander will use the new rotation properly.
- oldRotation: stores previous rotation value.
- fixed a couple of minor issues.
- included FLAs for the demos.