avocado-old/packages/graphics/sprite.js
2019-10-27 13:34:44 -05:00

33 lines
595 B
JavaScript

import {Sprite as PIXISprite} from '@pixi/sprite';
import {Renderable} from './renderable';
export class Sprite extends Renderable {
constructor(image) {
super();
this._image = image;
this.sprite = new PIXISprite(image.texture);
this.anchor = [0.5, 0.5];
}
get internal() {
return this.sprite;
}
get image() {
return this._image;
}
set sourceRectangle(rectangle) {
this._image.texture.frame = {
x: rectangle[0],
y: rectangle[1],
width: rectangle[2],
height: rectangle[3],
};
this._image.texture.updateUvs();
}
}