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. - **actor2D:** Add multiple hitbox support.
- **assets:** Add a way to get current relative frame
### Changed ### Changed
- **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors - **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 return self.frame
end end
function Animator:getRelativeFrame()
return self.frame - (self.animationData.startAt) + 1
end
function Animator:animationExist(name) function Animator:animationExist(name)
return (self.sprite.data.animations[self.currentAnimation] ~= nil) return (self.sprite.data.animations[self.currentAnimation] ~= nil)
end end

View file

@ -74,6 +74,10 @@ function Sprite:getDimensions()
return self.tileset:getDimensions() return self.tileset:getDimensions()
end end
function Sprite:getRelativeFrame()
return self.animator:getRelativeFrame()
end
-- DRAW FUNCTIONS -- DRAW FUNCTIONS
-- Draw sprites using these functions -- Draw sprites using these functions