From 53df3c125cdb9f9c53df9c82b552df1409489d40 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 5 May 2019 15:22:54 +0200 Subject: [PATCH] modules/world: add more wrapper around sprites functions --- gamecore/modules/world/actors/actor2D.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 3cf95bd..9c36ef7 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -99,6 +99,7 @@ end function Actor2D:update(dt) self:autoMove(dt) + self:updateSprite(dt) end -- MOVEMENT FUNCTIONS @@ -245,6 +246,22 @@ function Actor2D:cloneSprite() end end +function Actor2D:changeAnimation(animation, restart) + if (self.sprite.clone == nil) then + self.assets.sprites[self.sprite.name]:changeAnimation(animation, restart) + else + self.sprite.clone:changeAnimation(animation, restart) + end +end + +function Actor2D:setCustomSpeed(customSpeed) + if (self.sprite.clone == nil) then + self.assets.sprites[self.sprite.name]:setCustomSpeed(customSpeed) + else + self.sprite.clone:setCustomSpeed(customSpeed) + end +end + function Actor2D:updateSprite(dt) if (self.sprite.clone ~= nil) then self.sprite.clone:update(dt)