fix: start simplification of the movement system
This commit is contained in:
parent
75914d694d
commit
8fe8f61821
2 changed files with 17 additions and 20 deletions
|
@ -4,6 +4,10 @@ local Battler = Parent:extend()
|
|||
function Battler:new(world, x, y, z)
|
||||
Battler.super.new(self, world, x, y, z)
|
||||
|
||||
self.start = {}
|
||||
self.start.x = x
|
||||
self.start.y = y
|
||||
|
||||
self.isBattler = true
|
||||
self.speed = 3
|
||||
self.isActive = false
|
||||
|
|
|
@ -47,32 +47,21 @@ function Hero:initMovementSystem()
|
|||
self:initJump()
|
||||
end
|
||||
|
||||
function Hero:getMovementDuration(dx, dy, factor)
|
||||
local factor = factor or 1
|
||||
local duration = MOVEMENT_DURATION / factor
|
||||
local coef = 0.5
|
||||
local dx, dy = dx, dy
|
||||
local distance = utils.math.pointDistance(self.x, self.y, dx, dy) * coef
|
||||
return duration * distance
|
||||
end
|
||||
|
||||
function Hero:goTo(dx, dy, timerName, factor, easing)
|
||||
function Hero:goTo(dx, dy, duration, easing)
|
||||
local easing = easing or 'inOutQuad'
|
||||
local factor = factor or 1
|
||||
local duration = math.max(self:getMovementDuration(dx, dy, factor), 0.30)
|
||||
if duration > 0 then
|
||||
self.tweens:newTween(0, duration, {x = dx, y = dy}, easing)
|
||||
end
|
||||
self.tweens:newTimer(duration + 0.02, timerName)
|
||||
self.tweens:newTimer(duration + 0.02, "goTo")
|
||||
end
|
||||
|
||||
function Hero:jumpTo(dx, dy, size, timerName, spinjump, factor, easing)
|
||||
function Hero:jumpTo(dx, dy, sizeFactor, duration, spinjump, easing)
|
||||
local easing = easing or 'inOutQuad'
|
||||
local factor = factor or 1
|
||||
local duration = math.max(self:getMovementDuration(dx, dy, factor), 0.30)
|
||||
local dist = utils.math.pointDistance(self.x, self.y, dx, dy)
|
||||
local jumpHeight = dist * 8 * sizeFactor
|
||||
self.tweens:newTween(0, duration, {x = dx, y = dy}, easing)
|
||||
self.tweens:newTimer(duration + 0.02, timerName)
|
||||
self:setJump(size, spinjump, duration)
|
||||
self.tweens:newTimer(duration + 0.02, "jumpTo")
|
||||
self:setJump(jumpHeight, spinjump, duration)
|
||||
end
|
||||
|
||||
function Hero:updateSpeed(dt)
|
||||
|
@ -164,12 +153,16 @@ function Hero:unblockChoregraphy()
|
|||
self.currentlyBlocking = nil
|
||||
end
|
||||
|
||||
function Hero:receiveSignal(signal)
|
||||
if (self.currentlyBlocking ~= nil) then
|
||||
function Hero:timerResponse(signal)
|
||||
if ((self.currentlyBlocking ~= nil) and (signal == self.blockedBy)) then
|
||||
self:unblockChoregraphy()
|
||||
end
|
||||
end
|
||||
|
||||
function Hero:choregraphyEnded()
|
||||
self.direction = 1
|
||||
end
|
||||
|
||||
-- ASSETS FUNCTIONS
|
||||
-- Load and play assets needed by the character
|
||||
|
||||
|
|
Loading…
Reference in a new issue