2019-03-18 20:06:47 -05:00
|
|
|
export class Renderable {
|
|
|
|
|
2019-03-19 21:02:43 -05:00
|
|
|
constructor() {
|
|
|
|
this.parent = null;
|
|
|
|
this._zIndex = 0;
|
|
|
|
}
|
|
|
|
|
2019-03-18 20:06:47 -05:00
|
|
|
get alpha() {
|
|
|
|
return this.internal.alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
set alpha(alpha) {
|
|
|
|
this.internal.alpha = alpha;
|
|
|
|
}
|
|
|
|
|
2019-03-19 18:29:11 -05:00
|
|
|
destroy() {
|
2019-03-20 23:23:34 -05:00
|
|
|
if (this.internal) {
|
|
|
|
this.internal.destroy();
|
2019-03-25 18:54:54 -05:00
|
|
|
delete this.internal;
|
2019-03-20 23:23:34 -05:00
|
|
|
}
|
2019-03-19 18:29:11 -05:00
|
|
|
}
|
|
|
|
|
2019-03-18 20:06:47 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-03-25 18:55:06 -05:00
|
|
|
get scale() {
|
|
|
|
const scale = this.internal.scale || {x: 1, y: 1};
|
|
|
|
return [
|
|
|
|
scale.x,
|
|
|
|
scale.y,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
set scale(scale) {
|
|
|
|
this.internal.scale = {
|
|
|
|
x: scale[0],
|
|
|
|
y: scale[1]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-03-18 20:06:47 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-03-19 21:02:43 -05:00
|
|
|
get zIndex() {
|
|
|
|
return this._zIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
set zIndex(zIndex) {
|
|
|
|
if (this.parent) {
|
|
|
|
this.parent.isDirty = true;
|
|
|
|
}
|
|
|
|
this._zIndex = zIndex;
|
|
|
|
}
|
|
|
|
|
2019-03-18 20:06:47 -05:00
|
|
|
}
|
|
|
|
|