Constructor
new TravelerSkeleton(x, y, width, height)
Name | Type | Description |
---|---|---|
x |
Number | The initial x position of the TravelerSkeleton. |
y |
Number | The initial y position of the TravelerSkeleton. |
width |
Number | the width of the TravelerSkeleton |
height |
Number | the height of the TravelerSkeleton |
Members
_lastPos
Would hold the last known position of the TravlerSkeleton
_lastVeloc
Would hold the last known velocity of the TravelerSkeleton
_pos :MoverPoint
Holds the position of the TravelerSkeleton
_rect :Rectangle
_veloc :MoverPoint
Holds the velocity of the TravelerSkeleton
avoidDistance :Number
Default is 20.
- Number
avoidee :MoverSkeleton
avoidSpace :Number
Default is 20.
- Number
bird
bypassAvoidDistance :Boolean
- Boolean
circleDistance :Number
Used with the .circle method. Default is 10
- Number
dX :Number
For denoting horizontal direction
- Number
dY :Number
For denoting vertical direction
- Number
easeProximity :Number
Default is 2
- Number
followDistance :Number
- Number
forceHolder :MoverPoint
height
mass :Number
Default is 2
- Number
maxForce :Number
Default is 12
- Number
maxSpeed :Number
Default is 5
- Number
path :Array
- Array
personalSpace :Number
Default is 20.
- Number
separationDistance :Number
Default is 10
- Number
spreadDistance :Number
Used with the separate method. Default is 10
- Number
visionDistance :Number
Default is 20
- Number
wanderAngle :Number
Default is 10
- Number
wanderOffset
wanderProximity :Number
Default is 10
- Number
wanderRadius :Number
Default is 20
- Number
wanderRange :Number
Default is 20
- Number
width :Number
- Number
x :Number
Holding the x position
- Number
y :Number
Holding the y position
- Number
Methods
addEventListener(type, listenerString, object)
Name | Type | Description |
---|---|---|
type |
||
listenerString |
||
object |
align(withThese, priority)
Name | Type | Description |
---|---|---|
withThese |
Array | Array of other Travelers |
priority |
Number |
almostCloseTo(mp) → {Boolean}
Returns true if almost close to the MoverPoint
Name | Type | Description |
---|---|---|
mp |
MoverPoint |
- Type
- Boolean
avoid(moverSkeleton) → {Boolean}
Avoid the given Mover
Name | Type | Description |
---|---|---|
moverSkeleton |
MoverSkeleton |
- Type
- Boolean
avoidThese(these) → {Boolean}
Avoid the given Array of Movers.
Name | Type | Description |
---|---|---|
these |
Array | An Array of the Movers to avoid. |
- Type
- Boolean
canSeeThis(mp) → {Boolean}
Returns true if the MoverPoint is within visionDistance at the current velocity
Name | Type | Description |
---|---|---|
mp |
MoverPoint |
- Type
- Boolean
chase(target)
Chase the target given.
Name | Type | Description |
---|---|---|
target |
Mover | Traveler |
circle(mp)
Circle around the given MoverPoint position. Uses circleDistance
Name | Type | Description |
---|---|---|
mp |
MoverPoint | The MoverPoint to circle around. |
cohesion(withThese, cohesionPriority)
Name | Type | Description |
---|---|---|
withThese |
Array | Array of other Travelers |
cohesionPriority |
Number |
dispatchEvent(event)
Name | Type | Description |
---|---|---|
event |
easeAwayFrom(mp)
Ease away from the MoverPoint given.
Name | Type | Description |
---|---|---|
mp |
MoverPoint |
easeTo(mp)
Ease to the given MoverPoint. Uses easeProximity.
Name | Type | Description |
---|---|---|
mp |
MoverPoint |
evade(target)
Evade the given target
Name | Type | Description |
---|---|---|
target |
Mover | Traveler |
flee(mp)
Flee the given MoverPoint
Name | Type | Description |
---|---|---|
mp |
MoverPoint | the MoverPoint to flee |
flock(withThese, separatePriority, alignPriority, cohesionPriority)
separate, align, and cohesion together.
Name | Type | Description |
---|---|---|
withThese |
Array | Array of other Travelers |
separatePriority |
Number | |
alignPriority |
Number | |
cohesionPriority |
Number |
followPath(path, loopPath)
Follow the path of given MoverPoints; easeTo each MoverPoint.
Name | Type | Description |
---|---|---|
path |
Array | An Array of MoverPoints that make up the path. |
loopPath |
Boolean |
getAlignmentForce(withThese)
Name | Type | Description |
---|---|---|
withThese |
Array |
getCohesionForce(withThese)
Name | Type | Description |
---|---|---|
withThese |
getHeight() → {Number}
Returns the height of the TravelerSkeleton
- Type
- Number
getHideSpot(currentPosition, radius, from) → {MoverPoint}
Returns the MoverPoint position that is out of the given radius of from. Uses personalSpace. This method is used internally by the hide method.
Name | Type | Description |
---|---|---|
currentPosition |
MoverPoint | the current MoverPoint position to calculate the hide spot from. |
radius |
Number | The radius to use during calculations. |
from |
Mover | Traveler | The Mover to hide from. |
- Type
- MoverPoint
getHorizontalDirection() → {Number}
Returns the horizontal direction the TravelerSkeleton is moving typically 0 1 or -1.
- Type
- Number
getMaxForceSquared() → {Number}
Returns maxForce * maxForce;
- Type
- Number
getMiddle() → {MoverPoint}
Returns the middle position MoverPoint of the TravelerSkeleton
- Type
- MoverPoint
getPathIndex() → {Number}
Returns the _pathIndex
- Type
- Number
getPosition() → {MoverPoint}
Returns the MoverPoint position of the TravelerSkeleton
- Type
- MoverPoint
getRectangle(wOffset, hOffset) → {Rectangle}
Returns the rectangle bounds of the TravelerSkeleton
Name | Type | Description |
---|---|---|
wOffset |
Number | offset the width result by this amount |
hOffset |
Number | offset the height result by this amount |
- Type
- Rectangle
getSeparationForce(fromThese)
Name | Type | Description |
---|---|---|
fromThese |
Array |
getSteerForce(target, ease, easeDistance) → {MoverPoint}
Returns the force needed to steer towards the target given. Uses maxForce and maxSpeed.
Name | Type | Description |
---|---|---|
target |
Mover | Traveler | |
ease |
Boolean | If present ease the steer, otherwise just directly steer |
easeDistance |
Number | the amount of distance before easing should happen. |
- Type
- MoverPoint
getVelocity() → {MoverPoint}
Returns the current velocity (._veloc) MoverPoint
- Type
- MoverPoint
getVerticalDirection() → {Number}
Returns the vertical direction the TravelerSkeleton is moving typically 0 1 or -1.
- Type
- Number
getWidth() → {Number}
Returns the width of the TravelerSkeleton
- Type
- Number
getX() → {Number}
Returns the x position of the TravelerSkeleton
- Type
- Number
getY() → {Number}
Returns the y position of the TravelerSkeleton
- Type
- Number
hide(behindThese, from)
Hide behind the given Array of Movers, from the given Mover.
Name | Type | Description |
---|---|---|
behindThese |
Array | An Array of Movers/Travelers to hide behind. |
from |
Mover | Traveler | The Mover/Traveler to hide from. |
removeEventListener(type, listenerString, object)
Name | Type | Description |
---|---|---|
type |
||
listenerString |
||
object |
seek(mp)
Seek the given MoverPoint position.
Name | Type | Description |
---|---|---|
mp |
MoverPoint | The MoverPoint to seek. |
separate(withThese, separatePriority)
Separate from the other TravelerSkeletons in the withThese Array.
Name | Type | Description |
---|---|---|
withThese |
Array | an Array of TravelerSkeletons to separate from. |
separatePriority |
Number | A higher number will produce more separation. |
separateFromThis(mover)
Separate from the Mover given.
Name | Type | Description |
---|---|---|
mover |
Mover | Traveler |
setPathIndex(toThis)
Sets the pathIndex
Name | Type | Description |
---|---|---|
toThis |
Number |
setPosition(toThis)
Sets the MoverPoint position of the TravelerSkeleton
Name | Type | Description |
---|---|---|
toThis |
MoverPoint |
setVelocity(toThis)
Sets the current velocity MoverPoint
Name | Type | Description |
---|---|---|
toThis |
MoverPoint |
setX(toThis, notDX)
Sets the x position of the TravelerSkeleton
Name | Type | Description |
---|---|---|
toThis |
Number | the number to set the x position to. |
notDX |
Number | if present, the direction values of the TravelerSkeleton will not be updated. |
setY(toThis, notDY)
Sets the y position of the TravelerSkeleton
Name | Type | Description |
---|---|---|
toThis |
Number | |
notDY |
Number | if present the y direction value will not be updated. |
update()
Updates _lastPos _lastVeloc _unGrounded _npRight _npLeft and _unCeiling Gets overriden in other classes to do other additional things.
wander()
Wander aimlessly.