From 76fb15f8624150d57b68de45efa1c6fc4e932bdc Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 7 Sep 2019 20:52:20 +0200 Subject: [PATCH] feat(assets/animator): handle sending callbacks when animation end --- gamecore/modules/assets/animator.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gamecore/modules/assets/animator.lua b/gamecore/modules/assets/animator.lua index 53da4e4..b9d7a0f 100644 --- a/gamecore/modules/assets/animator.lua +++ b/gamecore/modules/assets/animator.lua @@ -120,6 +120,20 @@ function Animator:getDimensions() return self.sprite:getDimensions() end +-- CALLBACK FUNCTIONS +-- Handle getting a calback from the animation system + +function Animator:setCallbackTarget(callbackTarget) + self.callbackTarget = callbackTarget +end + +function Animator:sendCallback() + if (self.callbackTarget ~= nil) then + if (self.callbackTarget.animationEnded ~= nil) then + self.callbackTarget:animationEnded(self.currentAnimation) + end + end +end -- DRAW FUNCTIONS -- Draw animations using these functions