33 lines
595 B
JavaScript
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();
|
|
}
|
|
|
|
}
|