Fixed some issues with Sprite and TileSprite

This commit is contained in:
Arne van Iterson 2020-03-22 14:22:52 +01:00
parent 924af6745e
commit 5bc38b8e65
2 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,7 @@ class Sprite {
this.pos = { x: 0, y: 0 };
this.anchor = { x: 0, y: 0 };
this.scale = { x: 1, y: 1 };
this.pivot = { x: 0, y: 0 };
this.rotation = 0;
}
}

View File

@ -1,4 +1,5 @@
var Sprite = require("./Sprite");
var Sprite = require("./Sprite"),
AnimManager = require("./AnimManager");
class TileSprite extends Sprite {
constructor(texture, w, h) {
@ -6,6 +7,19 @@ class TileSprite extends Sprite {
this.tileW = w;
this.tileH = h;
this.frame = { x: 0, y: 0 };
this.anims = new AnimManager(this);
}
update(dt) {
this.anims.update(dt);
}
get w() {
return this.tileW * Math.abs(this.scale.x);
}
get h() {
return this.tileH * Math.abs(this.scale.y);
}
}