Package | com.gskinner.motion |
Class | public class Wander |
Property | Defined by | ||
---|---|---|---|
autoUpdate : Boolean Specifies whether the wander updates each frame automatically.
| Wander | ||
count : uint As the internal counter approaches count, it adds a exponentially derived value to strength, such that when the internal counter equals count, the trend strength will be 1.
| Wander | ||
data : Object Allows you to associate arbitrary data with this wander instance.
| Wander | ||
delayCount : uint Allows you to delay the effect of the count property by the specified number of frames.
| Wander | ||
innerRadius : Number The radius (from targetX and/or targetY) within which the target does not trend towards the target position.
| Wander | ||
oldRotation : Number Returns the previous rotation of the target.
| Wander | ||
oldX : Number Returns the previous x position of the target.
| Wander | ||
oldY : Number Returns the previous y position of the target.
| Wander | ||
onChange : Function This callback is called when count .
| Wander | ||
onComplete : Function This callback is called each frame while the wander is active.
| Wander | ||
outerRadius : Number The maximum distance (from targetX and/or targetY) the target can wander from the target position.
| Wander | ||
rotationLimit : Number Limits the maximum rotation change that the wander can make per update.
| Wander | ||
speed : Number The distance the target will travel each frame.
| Wander | ||
strength : Number The constant 0-1 strength applied to all active trends (based on targetX, targetY, or targetRotation).
| Wander | ||
target : DisplayObject The display object to move.
| Wander | ||
targetObject : DisplayObject A display object whose x/y will be used as targetX / targetY (ie.
| Wander | ||
targetRotation : Number The rotation in degrees the target will trend towards or NaN to disable.
| Wander | ||
targetX : Number The x position the target will trend towards or NaN to disable.
| Wander | ||
targetY : Number The y position the target will trend towards or NaN to disable.
| Wander | ||
varyRotation : Number The amount that the target will vary rotation randomly (ie.
| Wander | ||
varySpeed : Number The amount that the speed will vary randomly each frame.
| Wander |
Method | Defined by | ||
---|---|---|---|
Wander(target:DisplayObject, props:Object = null)
Creates a new wander instance.
| Wander | ||
getShortRotation(rot:Number):Number
[static] Helper function that returns the shortest equivalent rotation value.
| Wander | ||
reset(props:Object = null):void
Resets all of the instance's default properties except target, and applies the specified props.
| Wander | ||
update():void
Runs the next "frame" of the wander - varying the rotation according to the instance properties and moving forwards.
| Wander |
Method | Defined by | ||
---|---|---|---|
handleTick(evt:Event):void
| Wander |
autoUpdate | property |
autoUpdate:Boolean
[read-write]Specifies whether the wander updates each frame automatically. True by default. This can be used to pause / resume the motion. It can also be set to false and you can call .update() directly - for example, in a game with a central "tick" dispatcher.
Implementation public function get autoUpdate():Boolean
public function set autoUpdate(value:Boolean):void
count | property |
public var count:uint
As the internal counter approaches count, it adds a exponentially derived value to strength, such that when the internal counter equals count, the trend strength will be 1.
data | property |
public var data:Object
Allows you to associate arbitrary data with this wander instance.
delayCount | property |
public var delayCount:uint
Allows you to delay the effect of the count property by the specified number of frames.
innerRadius | property |
public var innerRadius:Number
The radius (from targetX and/or targetY) within which the target does not trend towards the target position.
oldRotation | property |
public var oldRotation:Number
Returns the previous rotation of the target.
oldX | property |
public var oldX:Number
Returns the previous x position of the target.
oldY | property |
public var oldY:Number
Returns the previous y position of the target.
onChange | property |
public var onChange:Function
This callback is called when count .
onComplete | property |
public var onComplete:Function
This callback is called each frame while the wander is active.
outerRadius | property |
public var outerRadius:Number
The maximum distance (from targetX and/or targetY) the target can wander from the target position. The strength of this trend increases exponentially as the target wanders away from the innerRadius and approaches the outerRadius.
rotationLimit | property |
public var rotationLimit:Number
Limits the maximum rotation change that the wander can make per update. Set to NaN to disable.
speed | property |
public var speed:Number
The distance the target will travel each frame.
strength | property |
public var strength:Number
The constant 0-1 strength applied to all active trends (based on targetX, targetY, or targetRotation). This is additive with strengths calculated from outerRadius and count.
target | property |
public var target:DisplayObject
The display object to move.
targetObject | property |
public var targetObject:DisplayObject
A display object whose x/y will be used as targetX / targetY (ie. the wander will follow the targetObject). Set to null to disable.
targetRotation | property |
public var targetRotation:Number
The rotation in degrees the target will trend towards or NaN to disable.
targetX | property |
public var targetX:Number
The x position the target will trend towards or NaN to disable.
targetY | property |
public var targetY:Number
The y position the target will trend towards or NaN to disable.
varyRotation | property |
public var varyRotation:Number
The amount that the target will vary rotation randomly (ie. wander). For example, a value of 0.5 would let the rotation vary by +/- 45 degrees each frame.
varySpeed | property |
public var varySpeed:Number
The amount that the speed will vary randomly each frame. For example, with a speed of 4 and varySpeed of 0.5, the speed will vary from 2 to 4.
Wander | () | constructor |
public function Wander(target:DisplayObject, props:Object = null)
Creates a new wander instance.
Parameterstarget:DisplayObject — Specifies the DisplayObject to move.
|
|
props:Object (default = null ) — Shortcut for setting properties on the new instance. All properties on this object are copied to the new instance. ex. {targetRotation:0, strength:0.1}
|
getShortRotation | () | method |
public static function getShortRotation(rot:Number):Number
Helper function that returns the shortest equivalent rotation value. For example, -90deg is a shorter equivalent of 270deg, and 15deg is equivalent to 375deg.
Parametersrot:Number |
Number |
handleTick | () | method |
protected function handleTick(evt:Event):void
Parameters
evt:Event |
reset | () | method |
public function reset(props:Object = null):void
Resets all of the instance's default properties except target, and applies the specified props.
Parametersprops:Object (default = null )
|
update | () | method |
public function update():void
Runs the next "frame" of the wander - varying the rotation according to the instance properties and moving forwards. This is called every frame when autoUpdate is true, or can be called directly.