I'm not able to get this to work well. The code I tried writing isPlu wrote:You can't, not really. You'll have to delay it manually:
Incidentally, this is exactly what anal and anim8 also do.Code: Select all
maxTime = 0.2 curTime = 0 function love.update( dt ) curTime = curTime + dt if curTime > maxTime then -- go to the next step of your animation curTime = curTime - maxTime -- for smoothness, don't just go back to 0 end end
Code: Select all
maxTime = 0.2
curTime = 0
function love.update(dt)
curTime = curTime + dt
world:update(dt)
if (curTime > maxTime) then
if playerimage == love.graphics.newImage("KnightRunRight1.png") then
playerimage = love.graphics.newImage("KnightTesting.png")
curTime = curTime - maxTime
end
if playerimage == love.graphics.newImage("KnightRunRight2.png") then
playerimage = love.graphics.newImage("KnightTesting.png")
curTime = curTime - maxTime
end
if playerimage == love.graphics.newImage("KnightDamaged.gif") then
playerimage = love.graphics.newImage("KnightTesting.gif")
curTime = curTime - maxTime
end
end
if health < 1 then
playerimage = love.graphics.newImage("KnightTesting.gif")
end
if love.keyboard.isDown("right") then
player.b:applyForce(500, 0)
playerimage = love.graphics.newImage("KnightRunRight1.png")
elseif love.keyboard.isDown("left") then
player.b:applyForce(-500, 0)
playerimage = love.graphics.newImage("KnightRunRight1.png")
end
if love.keyboard.isDown("up") then
player.b:applyForce(0, -100)
enemy.b:applyForce(0, -100)
playerimage = love.graphics.newImage("KnightJump.gif")
elseif love.keyboard.isDown("down") then
player.b:applyForce(0, 50)
playerimage = love.graphics.newImage("KnightIdle.gif")
end
if love.keyboard.isDown("x") then
playerimage = love.graphics.newImage("KnightStab.gif")
end