feat(assets): add a way to get current relative frame

This function return the current frame relative to the first frame of 
the current animation
This commit is contained in:
Kazhnuz 2019-06-23 14:23:51 +02:00
parent a3b6bcd499
commit 8a5692c1a1
3 changed files with 11 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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