* add a point to the trail * @param {number} x - x position * @param {number} y - y position
(x, y)
| 104 | * @param {number} y - y position |
| 105 | */ |
| 106 | addPoint(x, y) { |
| 107 | if (this._points.length > 0) { |
| 108 | const last = this._points[this._points.length - 1]; |
| 109 | const dx = x - last.x; |
| 110 | const dy = y - last.y; |
| 111 | if (dx * dx + dy * dy < this.minDistance * this.minDistance) { |
| 112 | return; |
| 113 | } |
| 114 | } |
| 115 | this._points.push({ x, y, age: 0 }); |
| 116 | if (this._points.length > this.maxPoints) { |
| 117 | this._points.shift(); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | /** @ignore */ |
| 122 | update(dt) { |