avocado-old/packages/graphics/renderable.js

74 lines
1.0 KiB
JavaScript

export class Renderable {
constructor() {
this.parent = null;
this._zIndex = 0;
}
get alpha() {
return this.internal.alpha;
}
set alpha(alpha) {
this.internal.alpha = alpha;
}
destroy() {
this.internal.destroy();
}
get position() {
return [this.internal.x, this.internal.y];
}
set position(position) {
this.internal.x = position[0];
this.internal.y = position[1];
}
get rotation() {
return this.internal.rotation;
}
set rotation(rotation) {
this.internal.rotation = rotation;
}
get visible() {
return this.internal.visible;
}
set visible(isVisible) {
this.internal.visible = isVisible;
}
get x() {
return this.internal.x;
}
set x(x) {
this.internal.x = x;
}
get y() {
return this.internal.y;
}
set y(y) {
this.internal.y = y;
}
get zIndex() {
return this._zIndex;
}
set zIndex(zIndex) {
if (this.parent) {
this.parent.isDirty = true;
}
this._zIndex = zIndex;
}
}