feat(assets): add a new getCurrentAnimation function

This commit is contained in:
Kazhnuz 2019-06-23 15:25:56 +02:00
parent 6fb3fecc95
commit dca4ece7fe
4 changed files with 19 additions and 0 deletions

View file

@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **world:** Add more wrapper around sprite functions in BaseActor
- **assets:** Add a new getCurrentAnimation function
### Changed
- **world2D:** Use a list for bodies (hitboxes, etc) and one other for actors

View file

@ -94,6 +94,10 @@ end
-- INFO FUNCTIONS
-- get information with these functions
function Animator:getCurrentAnimation()
return self.currentAnimation
end
function Animator:getAnimationDuration(animation)
return (self.animationData.endAt - self.animationData.startAt) / self.animationData.speed
end

View file

@ -66,6 +66,10 @@ end
-- INFO FUNCTIONS
-- get information with these functions
function Sprite:getCurrentAnimation()
return self.animator:getCurrentAnimation()
end
function Sprite:animationExist(name)
return self.animator:animationExist(name)
end

View file

@ -236,6 +236,15 @@ function BaseActor:setSpriteScallingY(sy)
self.sprite.sy = sy
end
function BaseActor:getCurrentAnimation()
if (self.sprite.clone == nil) then
self.assets.sprites[self.sprite.name]:getCurrentAnimation()
else
self.sprite.clone:getCurrentAnimation()
end
end
function BaseActor:getSpriteScalling()
return self.sprite.sx, self.sprite.sy
end