2020-04-19 19:44:52 +02:00
|
|
|
var Sprite = require("./Sprite"),
|
|
|
|
AnimManager = require("./AnimManager");
|
2019-12-31 15:33:27 +01:00
|
|
|
|
|
|
|
class TileSpriteXML extends Sprite {
|
2020-03-21 17:22:28 +01:00
|
|
|
constructor(texture, xml, index) {
|
|
|
|
super(texture);
|
|
|
|
var src = xml.array[index];
|
|
|
|
this.imgPos = { x: src["x"], y: src["y"] };
|
2020-04-29 13:49:05 +02:00
|
|
|
this.w = src["width"];
|
|
|
|
this.h = src["height"];
|
2020-04-19 19:44:52 +02:00
|
|
|
this.anims = new AnimManager(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
update(dt) {
|
|
|
|
this.anims.update(dt);
|
|
|
|
}
|
|
|
|
|
|
|
|
get w() {
|
2020-04-29 13:49:05 +02:00
|
|
|
return this.w * Math.abs(this.scale.x);
|
2020-04-19 19:44:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
get h() {
|
2020-04-29 13:49:05 +02:00
|
|
|
return this.h * Math.abs(this.scale.y);
|
2020-03-21 17:22:28 +01:00
|
|
|
}
|
2019-12-31 15:33:27 +01:00
|
|
|
}
|
|
|
|
|
2020-02-29 13:45:56 +01:00
|
|
|
module.exports = TileSpriteXML;
|