Update the object transform, called automatically by engine even when paused
()
| 128 | |
| 129 | /** Update the object transform, called automatically by engine even when paused */ |
| 130 | updateTransforms() |
| 131 | { |
| 132 | const parent = this.parent; |
| 133 | if (parent) |
| 134 | { |
| 135 | // compose with parent transform inline to avoid intermediate vector allocs |
| 136 | const mirror = parent.getMirrorSign(); |
| 137 | const lp = this.localPos, pp = parent.pos; |
| 138 | const lx = lp.x*mirror, ly = lp.y, pa = parent.angle; |
| 139 | if (pa) |
| 140 | { |
| 141 | const c = cos(-pa), s = sin(-pa); |
| 142 | this.pos = new Vector2(lx*c - ly*s + pp.x, lx*s + ly*c + pp.y); |
| 143 | } |
| 144 | else |
| 145 | this.pos = new Vector2(lx + pp.x, ly + pp.y); |
| 146 | this.angle = mirror*this.localAngle + pa; |
| 147 | } |
| 148 | |
| 149 | // update children |
| 150 | for (const child of this.children) |
| 151 | child.updateTransforms(); |
| 152 | } |
| 153 | |
| 154 | /** Update the object physics, called automatically by engine once each frame. Can be overridden to stop or change how physics works for an object. */ |
| 155 | updatePhysics() |
no test coverage detected