27 lines
508 B
JavaScript
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],
|
|
};
|
|
}
|
|
|
|
}
|