Constructor
new BlittedTraveler(source, canvasObject, fromRect, x, y, width, height, dt)
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
- Implements:
_cpos
_deltaTime
_destination
_inDelay
_playerRef
_source
- Implements:
_wallObject
addedAnimationChanges
alphaBitmapData
alphaPoint
ani
animationIndexOrder
- Implements:
animationSpecs
- Implements:
avoidDistance
avoidSpace
blankRect
blitIndex
boundingMethod
bypassAvoidDistance
circleDistance
constructor
currentAnimation
- Implements:
easeProximity
fillColor
followDistance
forceApplier
fromHeightOffset
- Implements:
fromRect :Rectangle
- Implements:
fromWidthOffset
- Implements:
fromXOffset
- Implements:
fromYOffset
- Implements:
health
lastAnim
mass
maxForce
maxSpeed
mergeAlpha
onlyHorizontalAnimations
personalSpace
separationDistance
spreadDistance
toPoint
- Implements:
toPoint
- Implements:
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)
Name | Type | Description |
---|---|---|
e |
Event |
- Implements:
- CanvasAnimation#_delayedFunction
animate(thrott)
implementation of CanvasAnimation.animate, BlittedTraveler fully implements CanvasAnimation.
Name | Type | Description |
---|---|---|
thrott |
- Implements:
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.
Name | Type | Description |
---|---|---|
bt |
BlittedTraveler | |
topCanvas |
CanvasObject | |
bottomCanvas |
CanvasObjet | |
sortRadius |
Number | |
offset |
Number |
- Type
- Boolean
blit(r, p, igf)
Uses fromRect and toPoint to draw from this._source onto this._canvas.
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)
Name | Type | Description |
---|---|---|
left |
||
right |
||
up |
||
down |
||
keepAniIndex |
||
noIdle |
- Implements:
changeFaceAnimation(toFace, keepAniIndex)
from CanvasAnimation
Name | Type | Description |
---|---|---|
toFace |
||
keepAniIndex |
- Implements:
changeLeftRightUpDownAnimation(left, right, up, down, dontKeepAniIndex)
Name | Type | Description |
---|---|---|
left |
||
right |
||
up |
||
down |
||
dontKeepAniIndex |
- Implements:
checkCurrentWayIsClear(wd) → {Boolean}
Uses a WayDeterminer to check if the current position is clear via the WayDeterminer.wayIsClear method.
Name | Type | Description |
---|---|---|
wd |
WayDeterminer |
- Type
- Boolean
checkFutureWayIsClear(wd) → {Boolean}
Uses a WayDeterminer to check if the future position is clear via the WayDeterminer.wayIsClear method.
Name | Type | Description |
---|---|---|
wd |
WayDeterminer |
- Type
- Boolean
checkPastWayIsClear(wd) → {Boolean}
Uses a WayDeterminer to check if the past position is clear.
Name | Type | Description |
---|---|---|
wd |
WayDeterminer |
- Type
- Boolean
defineAnimation(animationName, arrayOfXYIndexValues, yIndex)
From CanvasAnimation see CanvasAnimation, BlittedTraveler fully implements CanvasAnimation.
Name | Type | Description |
---|---|---|
animationName |
||
arrayOfXYIndexValues |
||
yIndex |
- Implements:
delayedAnimateAndBlitt(thrott, milliSecondDelay, animation, clearBeforeBlitt)
Delays a call to animate and blit
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.
- Implements:
- Type
- Boolean
getBlitType() → {String}
Returns the blit type, see setBlitType
- See:
-
- setBlitType
- Type
- String
getCanvas() → {CanvasObject}
- Type
- CanvasObject
getCAPosition(addedX, addedY) → {MoverPoint}
Returns the position but not a reference to _pos. _cpos and _addedPos are used by this method.
Name | Type | Description |
---|---|---|
addedX |
Number | |
addedY |
Number |
- Type
- MoverPoint
getDestination() → {MoverPoint}
Returns _destination
- Type
- MoverPoint
getDirectionOfAnimation(currentAni, onlyLeftRight, onlyUpDown) → {String}
Name | Type | Description |
---|---|---|
currentAni |
||
onlyLeftRight |
||
onlyUpDown |
- Implements:
- Type
- String
getPosition() → {MoverPoint}
Returns _pos
- Implements:
- Type
- MoverPoint
getSource() → {Image}
- Type
- Image
getWallObject() → {Rectangle}
- Type
- Rectangle
init(source, canvasObject, fromRect, x, y, width, height)
Used like a super method.
Name | Type | Description |
---|---|---|
source |
||
canvasObject |
||
fromRect |
||
x |
||
y |
||
width |
||
height |
- Implements:
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.
Name | Type | Description |
---|---|---|
toThis |
String | BlittedTraveler.JUST_COPY or BlittedTraveler.FILL_RECT_THEN_COPY or BlittedTraveler.COPY_THEN_COPY. |
setCanvas(toThis)
Name | Type | Description |
---|---|---|
toThis |
CanvasObject |
setDestination(toThis)
Sets _destination
Name | Type | Description |
---|---|---|
toThis |
setSource(toThis)
Name | Type | Description |
---|---|---|
toThis |
setWallObject(toThis)
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.