Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samme/phaser-track
Let things follow things
https://github.com/samme/phaser-track
phaser
Last synced: 14 days ago
JSON representation
Let things follow things
- Host: GitHub
- URL: https://github.com/samme/phaser-track
- Owner: samme
- Created: 2017-02-23T02:55:27.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-22T03:54:24.000Z (almost 7 years ago)
- Last Synced: 2024-12-25T08:12:22.595Z (about 1 month ago)
- Topics: phaser
- Language: CoffeeScript
- Homepage: https://samme.github.io/phaser-track/
- Size: 62.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![Screenshot](https://samme.github.io/phaser-track/screenshot.png)
[Demo](https://samme.github.io/phaser-track/)
Use
---### Start tracking another object
```javascript
obj.track(target, {
// Default options:
offsetX : 0,
offsetY : 0,
trackRotation : false,
rotateOffset : false,
disableBodyMoves : true
})
```- `obj` is a [Sprite][1] or [Emitter][2]
- `target` is a Display Object, a [Pointer][3], or any object with `x` and `y`
- `trackRotation`: match the object’s `rotation` to the target’s `rotation`
- `rotateOffset`: rotate the offset around the target by the target’s `rotation`
- `disableBodyMoves`: suspend the object’s physics movement while trackingAn Emitter moves its launch point ([emitX][4], [emitY][5]) to follow the target. A Sprite moves its [position][6].
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
```javascript
obj.untrack()
```Change Log
----------- 1.0.0 (2018-02-21) — Changed `track` arguments
- 0.1.3 (2017-02-27) — First NPM release[1]: http://phaser.io/docs/2.6.2/Phaser.Sprite.html
[2]: http://phaser.io/docs/2.6.2/Phaser.Particles.Arcade.Emitter.html
[3]: http://phaser.io/docs/2.6.2/Phaser.Pointer.html
[4]: http://phaser.io/docs/2.6.2/Phaser.Particles.Arcade.Emitter.html#emitX
[5]: http://phaser.io/docs/2.6.2/Phaser.Particles.Arcade.Emitter.html#emitY
[6]: http://phaser.io/docs/2.6.2/Phaser.Sprite.html#position