improvement(cbs): improve animation speed

This commit is contained in:
Kazhnuz 2019-08-15 08:57:47 +02:00
parent 5b1deadb8a
commit e2d788e012
2 changed files with 9 additions and 9 deletions

View file

@ -39,21 +39,21 @@ return {
startAt = 22, startAt = 22,
endAt = 26, endAt = 26,
loop = 26, loop = 26,
speed = 10, speed = 15,
pauseAtEnd = true, pauseAtEnd = true,
}, },
["hit2"] = { ["hit2"] = {
startAt = 28, startAt = 28,
endAt = 31, endAt = 31,
loop = 31, loop = 31,
speed = 10, speed = 15,
pauseAtEnd = true, pauseAtEnd = true,
}, },
["hit3"] = { ["hit3"] = {
startAt = 32, startAt = 32,
endAt = 36, endAt = 36,
loop = 36, loop = 36,
speed = 10, speed = 15,
pauseAtEnd = true, pauseAtEnd = true,
}, },
} }

View file

@ -74,15 +74,15 @@ function Hero:updateMoving(dt)
self.yprevious = self.y self.yprevious = self.y
-- Move the player toward its destination -- Move the player toward its destination
self.x = (self.x) + ((self.dx) - (self.x)) * dt*15 self.x = (self.x) + ((self.dx) - (self.x)) * dt*10
self.y = (self.y) + ((self.dy) - (self.y)) * dt*15 self.y = (self.y) + ((self.dy) - (self.y)) * dt*10
-- Calculate speed to calculate animation speed -- Calculate speed to calculate animation speed
local xspeed, yspeed = math.abs(self.x - self.xprevious), local xspeed, yspeed = math.abs(self.x - self.xprevious),
math.abs(self.y - self.yprevious) math.abs(self.y - self.yprevious)
local speed = math.sqrt(xspeed*xspeed + yspeed*yspeed) * 32 local speed = math.sqrt(xspeed*xspeed + yspeed*yspeed) * 32
self:setCustomSpeed(speed * 60) self:setCustomSpeed(speed * 10)
-- Handle direction -- Handle direction
local direction = utils.math.sign(self.x - self.xprevious) local direction = utils.math.sign(self.x - self.xprevious)
@ -114,14 +114,14 @@ function Hero:updateDirectionSelection(dt)
self.xprevious = self.x self.xprevious = self.x
self.yprevious = self.y self.yprevious = self.y
self.x = (self.x) + ((self.startx) - (self.x)) * dt*15 self.x = (self.x) + ((self.startx) - (self.x)) * dt*10
self.y = (self.y) + ((self.starty) - (self.y)) * dt*15 self.y = (self.y) + ((self.starty) - (self.y)) * dt*10
local xspeed, yspeed = math.abs(self.x - self.xprevious), local xspeed, yspeed = math.abs(self.x - self.xprevious),
math.abs(self.y - self.yprevious) math.abs(self.y - self.yprevious)
local speed = math.sqrt(xspeed*xspeed + yspeed*yspeed) * 32 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) local direction = utils.math.sign(self.x - self.xprevious)
if direction ~= 0 then if direction ~= 0 then
self.direction = direction self.direction = direction