Class: ReachTargetXY

hcje/sprites.ReachTargetXY(sprite, targetX, targetY)

Adjuster that completes when the sprite reaches a point. Note the dynamics should have been configured first. If not moving, the adjuster is marked as complete. Once completed, the velocity and acceleration are set to zero.

Constructor

new ReachTargetXY(sprite, targetX, targetY)

Construct the adjuster

Parameters:
Name Type Description
sprite module:hcje/sprites.Sprite

The target sprite.

targetX number

Destination x position.

targetY number

Destination y position.

Source:

Extends

Members

(protected) _sprite :module:hcje/sprites.Sprite

The underlying sprite.

Type:
Overrides:
Source:

onCompletion :module:hcje/sprites~onAdjustmentComplete

Type:
Overrides:
Source:

Methods

adjust(timeStamp, deltaT)

Perform the adjustment. This method will be called in the animation cycle.

Parameters:
Name Type Description
timeStamp DOMHighResTimeStamp

Current time stamp in ms.

deltaT number

Change in time in seconds.

Overrides:
Source:

isComplete() → {boolean}

Get completion state.

Overrides:
Source:
Returns:
Type
boolean

markComplete(reason)

Set as complete.

Parameters:
Name Type Description
reason *

Reason for completion. This is passed to the onCompletion callback if provided.

Overrides:
Source:

targetReached(velocity, value, target) → {boolean}

Check if point reached.

Parameters:
Name Type Description
velocity number

Approach velocity.

value number

Current value.

target number

Target value.

Source:
Returns:

True if reached.

Type
boolean