phaser-track
v1.0.0
Published
Let things follow things
Downloads
2
Readme
Use
Start tracking another object
obj.track(target, {
// Default options:
offsetX : 0,
offsetY : 0,
trackRotation : false,
rotateOffset : false,
disableBodyMoves : true
})
obj
is a Sprite or Emittertarget
is a Display Object, a Pointer, or any object withx
andy
trackRotation
: match the object’srotation
to the target’srotation
rotateOffset
: rotate the offset around the target by the target’srotation
disableBodyMoves
: suspend the object’s physics movement while tracking
An Emitter moves its launch point (emitX, emitY) to follow the target. A Sprite moves its position.
The object stops tracking only if
- the target is destroyed; or
- a Pointer target is deactivated; or
- you call
untrack
It doesn't stop tracking if the target is killed.
It will not track while its own exists
is false.
Stop tracking
obj.untrack()
Change Log
- 1.0.0 (2018-02-21) — Changed
track
arguments - 0.1.3 (2017-02-27) — First NPM release