Traveler

Traveler

A basic class able to utilize the TravelerSkeleton methods, extending TravelerSkeleton. It has methods for movement, but only basic bounds collision handling.


Constructor

new Traveler(x, y, width, height, dtopt)

Parameters:
Name Type Attributes Default Description
x Number
y Number
width Number
height Number
dt Number <optional>
.6666666667

Delta time, default is tabageos.TimeKeeper._sae

Members

_deltaTime

The deltaTime (based on the desired frame rate) for this Traveler, default is tabageos.TimeKeeper._sae. see tabageos.TimeKeeper.

_destination

A MoverPoint or MoverSkeleton that would be the target of travel for this Traveler.

_eventDispatcher

Optional holder for an EventDispatcher instance.

_wallObject

A Rectangle that should define the outermost bounds for this Traveler to travel within.

avoidDistance

avoidSpace

boundingMethod :function

One of the tabageos.BoundMethods bounding methods. If there is a _wallObject defined, this method would be used to bind the Traveler to the wall Object.

Type:
  • function

circleDistance

constructor

easeProximity

followDistance

Used by the followPath method

forceApplier

A MoverPoint used to store and update the forces; mass, maxSpeed, maxForce, being applied to the Travelers velocity. (_veloc)

mass

maxForce

maxSpeed

personalSpace

separationDistance

spreadDistance

travelType

A Function (one of the TravelerSkeleton methods) to call for traveling, used by the travel method.

visionDistance

wanderAngle

Used by the wander method

wanderOffset

Used by the wander method

wanderProximity

wanderRadius

Used by the wander method

wanderRange

Used by the wander method

Methods

getDestination() → {MoverPoint|MoverSkeleton}

Returns the _destination property

Returns:
Type
MoverPoint | MoverSkeleton

init(x, y, width, height)

Like super. Called during construction.

Parameters:
Name Type Description
x
y
width
height

move()

Updates the position and velocity of the Traveler (changes _veloc _pos and x and y) using forceApplier, maxForce, mass, _deltaTime, and maxSpeed.

forceApplier is truncated by maxForce and divided by mass, then forceApplier is applied to _veloc. _veloc is truncated by maxSpeed, and then _pos is updated based on _veloc. If a _wallObject is defined, the boundingMethod defined will be called, and then x and y are updated to match _pos.

setDestination(toThis)

Sets the _destination property.

Parameters:
Name Type Description
toThis MoverPoint | MoverSkeleton

setWallObject(toThis)

Sets the _wallObject property

Parameters:
Name Type Description
toThis Rectangle

travel(to)

If a travelType function is defined, this method will call the travelType with the to param of this method or otherwise the _destination property of the instance, then move is called.

The TravelerSkeleton methods update the forceApplier and the move method applies forceApplier to update the velocity and position of the Traveler.
Parameters:
Name Type Description
to MoverPoint | MoverSkeleton

The MoverPoint or MoverSkeleton to travel to.