From 1217ec0d1070c3dd6e2fc54f1a22ec2a161c38cd Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 18 Aug 2019 16:46:57 +0200 Subject: [PATCH] feat(hero): wait a bit before use the switchActiveBattler function --- .../scenes/battlesystem/actors/hero.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua index 6848e57..792dcf5 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua @@ -146,11 +146,11 @@ function Hero:receiveSignal(action_type, id) end if (action_type == "defend") then self.turnAction = "defend" - self.world:switchActiveBattler( ) + self:switchActiveBattler( ) elseif (action_type == "attack") then self:changeAnimation("hit1") else - self.world:switchActiveBattler( ) + self:switchActiveBattler( ) end end @@ -160,6 +160,12 @@ function Hero:receiveBackSignal() self:changeAnimation("walk") end +function Hero:timerResponse(timer) + if timer == "switchActiveBattler" then + self.world:switchActiveBattler() + end +end + -- ACTION FUNCTIONS -- All functions related to actions @@ -173,6 +179,10 @@ function Hero:validateAction() end end +function Hero:switchActiveBattler() + self.tweens:newTimer(0.15, "switchActiveBattler") +end + -- SPRITE FUNCTIONS -- Handle the hero sprite @@ -195,7 +205,7 @@ function Hero:animationEnded(animation) self:sendDamage(self.x + self.direction, self.y, 33, 100, false, false) core.debug:print("cbs/hero", "normal combo finished, switching actor") self:changeAnimation("idle") - self.world:switchActiveBattler( ) + self:switchActiveBattler( ) end end