From f60e56bf2e725f1e84b9bfed7a14779b7488a5a9 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 18 Jul 2021 09:34:05 +0200 Subject: [PATCH] feat(battler):add ways to stop moving --- .../scenes/battlesystem/actors/battler.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua index 5d1ff26..4918297 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua @@ -120,6 +120,18 @@ function Battler:initMovementSystem() self:initJump() end +function Battler:stopMoving() + self.xspeed, self.yspeed, self.zspeed = 0,0,0 + if (self.movementType == MOVEMENT_TWEENER) then + self:unlockTag("goTo") + self.tweens:removeNamedTween("goTo") + self.tweens:removeTimer("goTo") + self.tweens:removeTimer("resetMovement") + end + self.movementType = MOVEMENT_NONE + self:updatePreviousPosition() +end + function Battler:updateMovement(dt) if (self.movementType == MOVEMENT_TWEENER) then self:updateTweenerSpeed(dt) @@ -144,7 +156,7 @@ end function Battler:goTo(dx, dy, duration, easing) local easing = easing or 'inOutQuad' if duration > 0 then - self.tweens:newTween(0, duration, {x = dx, y = dy}, easing) + self.tweens:setNamedTween("goTo", 0, duration, {x = dx, y = dy}, easing) end self.tweens:newTimer(duration + 0.02, "goTo") self.tweens:newTimer(duration + 0.02, "resetMovement") @@ -197,6 +209,11 @@ function Battler:initJump() self.jump.isMotionJump = false end +function Battler:stopJumping() + self:initJump() + self.zspeed = 0 +end + function Battler:setJump(power, bounceNumber, useDefaultAnimation) self.zspeed = power self.jump.spin = (useDefaultAnimation == false)