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 - **world:** Add more wrapper around sprite functions in BaseActor
- **assets:** Add a new getCurrentAnimation function
### 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

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

View file

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

View file

@ -236,6 +236,15 @@ function BaseActor:setSpriteScallingY(sy)
self.sprite.sy = sy self.sprite.sy = sy
end 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() function BaseActor:getSpriteScalling()
return self.sprite.sx, self.sprite.sy return self.sprite.sx, self.sprite.sy
end end