123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- class Object2D extends GameObject
- {
- constructor(name)
- {
- super(name);
- this.position = Vector2.ZERO();
- this.rotationDegrees = 0;
- this.scale = Vector2.ONE();
- this.visible = true;
- }
- show()
- {
- this.visible = true;
- for (let i = 0; i < this.children.length; i++)
- {
- if(!this.children[i].show) continue;
- this.children[i].show();
- }
- }
- hide()
- {
- this.visible = false;
- for (let i = 0; i < this.children.length; i++)
- {
- if(!this.children[i].hide) continue;
- this.children[i].hide();
- }
- }
- setVisibility(val)
- {
- this.visible = val;
- for (let i = 0; i < this.children.length; i++)
- {
- if(!this.children[i].setVisibility) continue;
- this.children[i].setVisibility(val);
- }
- }
- getVisibility()
- {
- return this.visible;
- }
- draw(delta, db)
- {
- if (!this.visible) return;
- db.push();
- db.translate(this.position.x, this.position.y);
- db.rotate(this.rotationDegrees);
- db.scale(this.scale.x, this.scale.y);
- this._draw(delta, db);
- for (let i = 0; i < this.children.length; i++)
- this.children[i].draw(delta, db);
- db.pop()
- }
- }
|