Projektmanagement-Game/public/js/Sprite.js

22 lines
578 B
JavaScript
Raw Normal View History

function Sprite(x, y, slow) {
if(slow){
this.sprite = PIXI.Sprite.from('/img/spriteSlow.jpg');
}else{
this.sprite = PIXI.Sprite.from('/img/sprite.jpg');
}
2021-06-08 13:38:43 +00:00
this.coord_x = x;
this.coord_y = y;
this.getSprite = function () {
this.setSize(this.sprite, sprite_size);
return this.sprite;
2021-06-11 05:55:46 +00:00
};
2021-06-08 13:38:43 +00:00
this.setSize = function (sprite, size) {
sprite.x = this.coord_x * size - size * 0.2;
sprite.y = this.coord_y * size - size * 0.2;
sprite.width = size * 1.5;
sprite.height = size * 1.5;
2021-06-11 05:55:46 +00:00
};
}