2019-03-18 20:06:47 -05:00
|
|
|
const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined;
|
|
|
|
|
|
|
|
import {Renderable} from './renderable';
|
|
|
|
|
|
|
|
export class Sprite extends Renderable {
|
|
|
|
|
|
|
|
constructor(image) {
|
|
|
|
super();
|
|
|
|
this._image = image;
|
2019-03-25 10:18:41 -05:00
|
|
|
this.sprite = new PIXI.Sprite(image.texture);
|
2019-04-19 16:32:17 -05:00
|
|
|
this.anchor = [0.5, 0.5];
|
2019-03-25 10:18:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
get internal() {
|
|
|
|
return this.sprite;
|
2019-03-18 20:06:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
get image() {
|
|
|
|
return this._image;
|
|
|
|
}
|
|
|
|
|
2019-03-18 22:19:43 -05:00
|
|
|
set sourceRectangle(rectangle) {
|
2019-03-18 20:06:47 -05:00
|
|
|
this._image.texture.frame = {
|
|
|
|
x: rectangle[0],
|
|
|
|
y: rectangle[1],
|
|
|
|
width: rectangle[2],
|
|
|
|
height: rectangle[3],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|