MCPcopy Create free account
hub / github.com/melonjs/melonJS / update

Method update

packages/melonjs/src/renderable/trail.js:122–144  ·  view source on GitHub ↗

@ignore

(dt)

Source from the content-addressed store, hash-verified

120
121 /** @ignore */
122 update(dt) {
123 if (this.target) {
124 const pos = this.target.pos ?? this.target;
125 this.addPoint(pos.x, pos.y);
126 }
127
128 const pts = this._points;
129 let expired = 0;
130 for (let i = 0; i < pts.length; i++) {
131 pts[i].age += dt;
132 // oldest points are at the front, count the contiguous expired block
133 if (i === expired && pts[i].age >= this.lifetime) {
134 expired++;
135 }
136 }
137 if (expired > 0) {
138 pts.splice(0, expired);
139 }
140
141 this.inViewport = this._points.length > 1;
142 this.isDirty = this._points.length > 1;
143 return super.update(dt);
144 }
145
146 /** @ignore */
147 draw(renderer) {

Callers

nothing calls this directly

Calls 1

addPointMethod · 0.95

Tested by

no test coverage detected