diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cfdb3e..53471b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **actor2D:** Add multiple hitbox support. +- **assets:** Add a way to get current relative frame + + ### Changed - **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors diff --git a/gamecore/modules/assets/animator.lua b/gamecore/modules/assets/animator.lua index 1498153..6aced5a 100644 --- a/gamecore/modules/assets/animator.lua +++ b/gamecore/modules/assets/animator.lua @@ -102,6 +102,10 @@ function Animator:getFrame() return self.frame end +function Animator:getRelativeFrame() + return self.frame - (self.animationData.startAt) + 1 +end + function Animator:animationExist(name) return (self.sprite.data.animations[self.currentAnimation] ~= nil) end diff --git a/gamecore/modules/assets/sprites.lua b/gamecore/modules/assets/sprites.lua index ddf4f89..63676a2 100644 --- a/gamecore/modules/assets/sprites.lua +++ b/gamecore/modules/assets/sprites.lua @@ -74,6 +74,10 @@ function Sprite:getDimensions() return self.tileset:getDimensions() end +function Sprite:getRelativeFrame() + return self.animator:getRelativeFrame() +end + -- DRAW FUNCTIONS -- Draw sprites using these functions