feat(assets): add more wrapper around sprite functions in BaseActor

This commit is contained in:
Kazhnuz 2019-06-23 14:27:07 +02:00
parent 531f3c5803
commit 6fb3fecc95
2 changed files with 32 additions and 0 deletions

View file

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

View file

@ -240,6 +240,36 @@ function BaseActor:getSpriteScalling()
return self.sprite.sx, self.sprite.sy
end
function BaseActor:getFrame()
if (self.sprite.name ~= nil) then
if (self.sprite.clone ~= nil) then
self.sprite.clone:getFrame()
else
self.assets.sprites[self.sprite.name]:getFrame()
end
end
end
function BaseActor:getRelativeFrame()
if (self.sprite.name ~= nil) then
if (self.sprite.clone ~= nil) then
self.sprite.clone:getRelativeFrame()
else
self.assets.sprites[self.sprite.name]:getRelativeFrame()
end
end
end
function BaseActor:getAnimationDuration()
if (self.sprite.name ~= nil) then
if (self.sprite.clone ~= nil) then
self.sprite.clone:getAnimationDuration()
else
self.assets.sprites[self.sprite.name]:getAnimationDuration()
end
end
end
function BaseActor:drawSprite(x, y, r, sx, sy, ox, oy, kx, ky)
if (self.sprite.name ~= nil) then
local x = x + self.sprite.ox