avocado-old/packages/graphics/sprite.js
2019-03-18 20:06:47 -05:00

27 lines
508 B
JavaScript

const PIXI = 'undefined' !== typeof window ? require('pixi.js') : undefined;
import {Renderable} from './renderable';
export class Sprite extends Renderable {
constructor(image) {
super();
this._image = image;
this.internal = new PIXI.Sprite(image.texture);
}
get image() {
return this._image;
}
setSourceRectangle(rectangle) {
this._image.texture.frame = {
x: rectangle[0],
y: rectangle[1],
width: rectangle[2],
height: rectangle[3],
};
}
}