From 5bc38b8e6587c3fd023800f4438e764a97319f12 Mon Sep 17 00:00:00 2001 From: Arne van Iterson Date: Sun, 22 Mar 2020 14:22:52 +0100 Subject: [PATCH] Fixed some issues with Sprite and TileSprite --- lib/Sprite.js | 1 + lib/TileSprite.js | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Sprite.js b/lib/Sprite.js index 6e7d550..ddf9fb0 100644 --- a/lib/Sprite.js +++ b/lib/Sprite.js @@ -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; } } diff --git a/lib/TileSprite.js b/lib/TileSprite.js index 5c98763..fe9d283 100644 --- a/lib/TileSprite.js +++ b/lib/TileSprite.js @@ -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); } }