feat(actor/player): add three-hit combo

This commit is contained in:
Kazhnuz 2019-08-01 08:45:13 +02:00
parent ca3bf9ea7e
commit 24e7fe8ee8
3 changed files with 52 additions and 7 deletions

View file

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View file

@ -12,27 +12,51 @@ function Player:new(world, x, y, z, id)
self.guiborder = game.gui.newBorder(424, 20, 6)
self.emblem = love.graphics.newImage("assets/gui/emblem_speedster.png")
self.status = love.graphics.newImage("assets/gui/status_bar.png")
self.action = "normal"
end
function Player:updateStart(dt)
self.xfrc, self.yfrc = 480*3, 480*3
if self.keys["up"].isDown then
if self.keys["up"].isDown and (self.action ~= "punching") then
self.ysp = -160
end
if self.keys["down"].isDown then
if self.keys["down"].isDown and (self.action ~= "punching") then
self.ysp = 160
end
if self.keys["left"].isDown then
if self.keys["left"].isDown and (self.action ~= "punching") then
self.xsp = -160
end
if self.keys["right"].isDown then
if self.keys["right"].isDown and (self.action ~= "punching") then
self.xsp = 160
end
if self.keys["A"].isDown and (self.onGround) then
if self.keys["A"].isDown and (self.onGround) and (self.action ~= "punching") then
self.zsp = 280*1.33
end
if self.keys["B"].isPressed and (self.onGround) then
self.action = "punching"
self.xsp = 0
self.zsp = 0
if self:getCurrentAnimation() == "hit1" then
self:changeAnimation("hit2", true)
elseif self:getCurrentAnimation() == "hit2" then
self:changeAnimation("hit3", true)
elseif self:getCurrentAnimation() == "hit3" then
--self:changeAnimation("hit1", true)
else
self:changeAnimation("hit1", true)
end
end
end
function Player:animationEnded(name)
if (name == "hit1") or (name == "hit2") or (name == "hit3") then
self.action = "normal"
end
end
function Player:updateEnd(dt)
@ -43,8 +67,8 @@ function Player:setAnimation()
local gsp = utils.math.pointDistance(0, 0, self.xsp, self.ysp)
self:setCustomSpeed(math.abs(gsp) / 12)
self:setDirection(self.xsp)
if (self.isPunching) then
self:changeAnimation("walk", false)
if (self.action == "punching") then
--the animation system is already active
else
if (self.onGround) then
if (math.abs(self.xsp) > 0) or (math.abs(self.ysp) > 0) then