improvement(cbs): improve animation speed
This commit is contained in:
parent
5b1deadb8a
commit
e2d788e012
2 changed files with 9 additions and 9 deletions
|
@ -39,21 +39,21 @@ return {
|
|||
startAt = 22,
|
||||
endAt = 26,
|
||||
loop = 26,
|
||||
speed = 10,
|
||||
speed = 15,
|
||||
pauseAtEnd = true,
|
||||
},
|
||||
["hit2"] = {
|
||||
startAt = 28,
|
||||
endAt = 31,
|
||||
loop = 31,
|
||||
speed = 10,
|
||||
speed = 15,
|
||||
pauseAtEnd = true,
|
||||
},
|
||||
["hit3"] = {
|
||||
startAt = 32,
|
||||
endAt = 36,
|
||||
loop = 36,
|
||||
speed = 10,
|
||||
speed = 15,
|
||||
pauseAtEnd = true,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -74,15 +74,15 @@ function Hero:updateMoving(dt)
|
|||
self.yprevious = self.y
|
||||
|
||||
-- Move the player toward its destination
|
||||
self.x = (self.x) + ((self.dx) - (self.x)) * dt*15
|
||||
self.y = (self.y) + ((self.dy) - (self.y)) * dt*15
|
||||
self.x = (self.x) + ((self.dx) - (self.x)) * dt*10
|
||||
self.y = (self.y) + ((self.dy) - (self.y)) * dt*10
|
||||
|
||||
-- Calculate speed to calculate animation speed
|
||||
local xspeed, yspeed = math.abs(self.x - self.xprevious),
|
||||
math.abs(self.y - self.yprevious)
|
||||
|
||||
local speed = math.sqrt(xspeed*xspeed + yspeed*yspeed) * 32
|
||||
self:setCustomSpeed(speed * 60)
|
||||
self:setCustomSpeed(speed * 10)
|
||||
|
||||
-- Handle direction
|
||||
local direction = utils.math.sign(self.x - self.xprevious)
|
||||
|
@ -114,14 +114,14 @@ function Hero:updateDirectionSelection(dt)
|
|||
self.xprevious = self.x
|
||||
self.yprevious = self.y
|
||||
|
||||
self.x = (self.x) + ((self.startx) - (self.x)) * dt*15
|
||||
self.y = (self.y) + ((self.starty) - (self.y)) * dt*15
|
||||
self.x = (self.x) + ((self.startx) - (self.x)) * dt*10
|
||||
self.y = (self.y) + ((self.starty) - (self.y)) * dt*10
|
||||
|
||||
local xspeed, yspeed = math.abs(self.x - self.xprevious),
|
||||
math.abs(self.y - self.yprevious)
|
||||
|
||||
local speed = math.sqrt(xspeed*xspeed + yspeed*yspeed) * 32
|
||||
self:setCustomSpeed(speed * 60)
|
||||
self:setCustomSpeed(speed * 10)
|
||||
local direction = utils.math.sign(self.x - self.xprevious)
|
||||
if direction ~= 0 then
|
||||
self.direction = direction
|
||||
|
|
Loading…
Reference in a new issue