feat(battler):add ways to stop moving

This commit is contained in:
Kazhnuz 2021-07-18 09:34:05 +02:00
parent 14e93a2880
commit f60e56bf2e

View file

@ -120,6 +120,18 @@ function Battler:initMovementSystem()
self:initJump() self:initJump()
end 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) function Battler:updateMovement(dt)
if (self.movementType == MOVEMENT_TWEENER) then if (self.movementType == MOVEMENT_TWEENER) then
self:updateTweenerSpeed(dt) self:updateTweenerSpeed(dt)
@ -144,7 +156,7 @@ end
function Battler:goTo(dx, dy, duration, easing) function Battler:goTo(dx, dy, duration, easing)
local easing = easing or 'inOutQuad' local easing = easing or 'inOutQuad'
if duration > 0 then 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 end
self.tweens:newTimer(duration + 0.02, "goTo") self.tweens:newTimer(duration + 0.02, "goTo")
self.tweens:newTimer(duration + 0.02, "resetMovement") self.tweens:newTimer(duration + 0.02, "resetMovement")
@ -197,6 +209,11 @@ function Battler:initJump()
self.jump.isMotionJump = false self.jump.isMotionJump = false
end end
function Battler:stopJumping()
self:initJump()
self.zspeed = 0
end
function Battler:setJump(power, bounceNumber, useDefaultAnimation) function Battler:setJump(power, bounceNumber, useDefaultAnimation)
self.zspeed = power self.zspeed = power
self.jump.spin = (useDefaultAnimation == false) self.jump.spin = (useDefaultAnimation == false)