KilledByAPixel/LittleJS

`this.addChild()` doesn't calculate position correctly during `pause`

Closed this issue · 1 comments

rndD commented

To reproduce:

setPaused(!paused);

And create a few Objects during pause:

class Button extends EngineObject {
  text: string;
  constructor() {
    super(vec2(0, 0), vec2(1, 1));
    this.text = text;
    
    this.color = hsl(0, 0, 1);
  }
}

export class Menu extends EngineObject {
  constructor() {
    const pos = screenToWorld(
      vec2(mainCanvas.width / 2, mainCanvas.height / 2)
    );
    super(pos, vec2(40));
    this.color = hsl(0, 0, 0, 0.8);
    const b = new Button();
    this.addChild(b, vec2(0, 0));
    const b2 = new Button();
    this.addChild(b2, vec2(10, 0));
  }
}

i just checked in a fix! new function updateTransforms is called even when paused

d5ae43f