BlittedTraveler

BlittedTraveler

A Traveler that implements CanvasAnimation. It has separate methods that can use a WayDeterminer for collision, but has no collision stuffs during its update/move method.


Constructor

new BlittedTraveler(source, canvasObject, fromRect, x, y, width, height, dt)

Parameters:
Name Type Description
source Image

An Img element to draw from.

canvasObject CanvasObject

the CanvasObject to draw on.

fromRect Rectangle

The Rectangle area in the source to draw from.

x Number

x location of the BlittedTraveler

y Number

y location of the Boolean

width Number

Width of the BlittedTraveler

height Number

Height of the BlittedTraveler

dt Number

Delta time, default is tabageos.TimeKeeper._sae

Implements:

Members

_addedPos

_autoAnimate

_blitType

_canvas

_cpos

_deltaTime

_destination

_inDelay

_playerRef

_source

_wallObject

addedAnimationChanges

alphaBitmapData

alphaPoint

ani

animationIndexOrder

animationSpecs

avoidDistance

avoidSpace

blankRect

blitIndex

boundingMethod

bypassAvoidDistance

circleDistance

constructor

currentAnimation

easeProximity

fillColor

followDistance

forceApplier

fromHeightOffset

fromRect :Rectangle

Type:

fromWidthOffset

fromXOffset

fromYOffset

health

lastAnim

mass

maxForce

maxSpeed

mergeAlpha

onlyHorizontalAnimations

personalSpace

separationDistance

spreadDistance

toPoint

toPoint

travelType

visionDistance

wanderAngle

wanderOffset

wanderProximity

wanderRadius

wanderRange

Methods

_autoAnimation()

calls changeDirectionAnimation then animate then blit or _canvas.context.fillRect if there is no _source or currentAnimation.

_delayedFunction(e)

Parameters:
Name Type Description
e Event
Implements:
  • CanvasAnimation#_delayedFunction

animate(thrott)

implementation of CanvasAnimation.animate, BlittedTraveler fully implements CanvasAnimation.

Parameters:
Name Type Description
thrott

basicDepthSort(bt, topCanvas, bottomCanvas, sortRadius, offset) → {Boolean}

Sorts and sets each _canvas property of this instance and the other BlittedTraveler passed. The one with the greater y plus offset will be on the topCanvas.

Parameters:
Name Type Description
bt BlittedTraveler
topCanvas CanvasObject
bottomCanvas CanvasObjet
sortRadius Number
offset Number
Returns:
Type
Boolean

blit(r, p, igf)

Uses fromRect and toPoint to draw from this._source onto this._canvas.

Parameters:
Name Type Description
r Rectanlge

An alternate fromRect to draw from, default is fromRect which is changed by the animate function.

p MoverPoint

An alternate toPoint to draw to, default is this.x and this.y.

igf Boolean

Ignore fromWidthOffset and fromHeightOffset if set fromWidth/HeightOfsset will be ignored.

Implements:

changeDirectionAnimation(left, right, up, down, keepAniIndex, noIdle)

Parameters:
Name Type Description
left
right
up
down
keepAniIndex
noIdle

changeFaceAnimation(toFace, keepAniIndex)

from CanvasAnimation

Parameters:
Name Type Description
toFace
keepAniIndex

changeLeftRightUpDownAnimation(left, right, up, down, dontKeepAniIndex)

Parameters:
Name Type Description
left
right
up
down
dontKeepAniIndex

checkCurrentWayIsClear(wd) → {Boolean}

Uses a WayDeterminer to check if the current position is clear via the WayDeterminer.wayIsClear method.

Parameters:
Name Type Description
wd WayDeterminer
Returns:
Type
Boolean

checkFutureWayIsClear(wd) → {Boolean}

Uses a WayDeterminer to check if the future position is clear via the WayDeterminer.wayIsClear method.

Parameters:
Name Type Description
wd WayDeterminer
Returns:
Type
Boolean

checkPastWayIsClear(wd) → {Boolean}

Uses a WayDeterminer to check if the past position is clear.

Parameters:
Name Type Description
wd WayDeterminer
Returns:
Type
Boolean

defineAnimation(animationName, arrayOfXYIndexValues, yIndex)

From CanvasAnimation see CanvasAnimation, BlittedTraveler fully implements CanvasAnimation.

Parameters:
Name Type Description
animationName
arrayOfXYIndexValues
yIndex

delayedAnimateAndBlitt(thrott, milliSecondDelay, animation, clearBeforeBlitt)

Delays a call to animate and blit

Parameters:
Name Type Description
thrott Number

The throttle to use for the animate call.

milliSecondDelay Number

The amount of time in milliseconds to wait before calling animate and blit

animation String

The currentAnimation to use.

clearBeforeBlitt Boolean

Clear the canvas before blit, default is false.

finishedCurrentAnimation() → {Boolean}

Returns true if the current animation has finished.

Returns:
Type
Boolean

getBlitType() → {String}

Returns the blit type, see setBlitType

See:
  • setBlitType
Returns:
Type
String

getCanvas() → {CanvasObject}

Returns:
Type
CanvasObject

getCAPosition(addedX, addedY) → {MoverPoint}

Returns the position but not a reference to _pos. _cpos and _addedPos are used by this method.

Parameters:
Name Type Description
addedX Number
addedY Number
Returns:
Type
MoverPoint

getDestination() → {MoverPoint}

Returns _destination

Returns:
Type
MoverPoint

getDirectionOfAnimation(currentAni, onlyLeftRight, onlyUpDown) → {String}

Parameters:
Name Type Description
currentAni
onlyLeftRight
onlyUpDown
Returns:
Type
String

getPosition() → {MoverPoint}

Returns _pos

Returns:
Type
MoverPoint

getSource() → {Image}

Returns:
Type
Image

getWallObject() → {Rectangle}

Returns:
Type
Rectangle

init(source, canvasObject, fromRect, x, y, width, height)

Used like a super method.

Parameters:
Name Type Description
source
canvasObject
fromRect
x
y
width
height
Implements:
Returns:

move()

Applies forceApplier to _veloc with maxForce and mass. then truncates _veloc to maxSpeed. then adds _veloc to _pos. If a .wallObject is defined and a .boundingMethod definded, _pos will be updated by the boundingMehtod. then _pos is applied to x and y.

In this class update and move do the same thing, you can call either one for movement.

setBlitType(toThis)

Set the blit type. Default is BlittedTraveler.JUST_COPY which just copies the animation onto the canvas. A blit type of BlittedTraveler.FILL_RECT_THEN_COPY will fill the animation area with the .fillColor color first then copy the animation over the same spot. A blit type of BlittedTraveler.COPY_THEN_COPY will copy with the .blankRect first.

Parameters:
Name Type Description
toThis String

BlittedTraveler.JUST_COPY or BlittedTraveler.FILL_RECT_THEN_COPY or BlittedTraveler.COPY_THEN_COPY.

Returns:

setCanvas(toThis)

Parameters:
Name Type Description
toThis CanvasObject

setDestination(toThis)

Sets _destination

Parameters:
Name Type Description
toThis

setSource(toThis)

Parameters:
Name Type Description
toThis

setWallObject(toThis)

Parameters:
Name Type Description
toThis

travel()

call travelType with _destination, then move then blit

update()

Applies forceApplier to _veloc with maxForce and mass. then truncates _veloc to maxSpeed. then adds _veloc to _pos. If a .wallObject is defined and a .boundingMethod definded, _pos will be updated by the boundingMehtod. then _pos is applied to x and y.