Sprite2D.js 557 B

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