Object2D.js 522 B

12345678910111213141516171819202122232425
  1. class Object2D extends GameObject
  2. {
  3. constructor(name)
  4. {
  5. super(name);
  6. this.position = Vector2.ZERO();
  7. this.rotationDegrees = 0;
  8. this.scale = Vector2.ONE();
  9. }
  10. draw(delta)
  11. {
  12. push();
  13. translate(this.position.x, this.position.y);
  14. rotate(this.rotationDegrees);
  15. scale(this.scale.x, this.scale.y);
  16. this._draw(delta);
  17. for (let i = 0; i < this.children.length; i++)
  18. this.children[i].draw(delta);
  19. pop()
  20. }
  21. }