asdf-games/lib/TileSpriteXML.js

27 lines
532 B
JavaScript
Raw Normal View History

2020-04-19 19:44:52 +02:00
var Sprite = require("./Sprite"),
AnimManager = require("./AnimManager");
class TileSpriteXML extends Sprite {
constructor(texture, xml, index) {
super(texture);
var src = xml.array[index];
this.imgPos = { x: src["x"], y: src["y"] };
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() {
return this.w * Math.abs(this.scale.x);
2020-04-19 19:44:52 +02:00
}
get h() {
return this.h * Math.abs(this.scale.y);
}
}
2020-02-29 13:45:56 +01:00
module.exports = TileSpriteXML;