trouble making an animation
Posted: Sat Jun 10, 2023 4:38 pm
Hello, good morning, I'm new to the developer forums, and I have a question about a code that I'm doing, more specifically it's an animation
function love.load()
fragmentos = 0
animacion = false
end
function love.update(dt)
if animacion == true then
fragmentos = fragmentos + 1 * dt
end
end
function.love.draw()
fragmentos = math.floor(fragmentos)
if animacion == true then
for i = 0, 6 do
if fragmentos == 1 then
love.graphics.draw(tragamonedas1, 0, 0)
fragmentos = 1
elseif fragmentos == 2 then
love.graphics.draw(tragamonedas2, 0, 0)
fragmentos = 2
elseif fragmentos == 3 then
love.graphics.draw(tragamonedas3, 0, 0)
elseif fragmentos == 4 then
love.graphics.draw(tragamonedas4, 0, 0)
elseif fragmentos == 5 then
love.graphics.draw(tragamonedas5, 0, 0)
elseif fragmentos == 6 then
love.graphics.draw(tragamonedas6, 0, 0)
elseif fragmentos == 7 then
love.graphics.draw(tragamonedas7, 0, 0)
elseif fragmentos == 8 then
love.graphics.draw(tragamonedas8, 0, 0)
elseif fragmentos == 9 then
love.graphics.draw(tragamonedas9, 0, 0)
elseif fragmentos == 10 then
love.graphics.draw(tragamonedas10, 0, 0)
elseif fragmentos == 11 then
love.graphics.draw(tragamonedas11, 0, 0)
elseif fragmentos == 12 then
love.graphics.draw(tragamonedas12, 0, 0)
elseif fragmentos == 13 then
love.graphics.draw(tragamonedas13, 0, 0)
elseif fragmentos == 14 then
love.graphics.draw(tragamonedas14, 0, 0)
elseif fragmentos == 15 then
love.graphics.draw(tragamonedas15, 0, 0)
elseif fragmentos == 16 then
love.graphics.draw(tragamonedas16, 0, 0)
elseif fragmentos == 17 then
love.graphics.draw(tragamonedas17, 0, 0)
elseif fragmentos == 18 then
love.graphics.draw(tragamonedas18, 0, 0)
elseif fragmentos == 19 then
love.graphics.draw(tragamonedas19, 0, 0)
elseif fragmentos == 20 then
love.graphics.draw(tragamonedas20, 0, 0)
elseif fragmentos == 21 then
love.graphics.draw(tragamonedas21, 0, 0)
elseif fragmentos == 22 then
love.graphics.draw(tragamonedas22, 0, 0)
elseif fragmentos == 23 then
love.graphics.draw(tragamonedas23, 0, 0)
elseif fragmentos == 24 then
love.graphics.draw(tragamonedas24, 0, 0)
fragmentos = 0
end
end
end
end
My problem is that it has to repeat the animation 6 times, but it does it infinitely, or when I manage to make it stop it only does it once and it does it too fast. Could anyone help me please. Thanks
function love.load()
fragmentos = 0
animacion = false
end
function love.update(dt)
if animacion == true then
fragmentos = fragmentos + 1 * dt
end
end
function.love.draw()
fragmentos = math.floor(fragmentos)
if animacion == true then
for i = 0, 6 do
if fragmentos == 1 then
love.graphics.draw(tragamonedas1, 0, 0)
fragmentos = 1
elseif fragmentos == 2 then
love.graphics.draw(tragamonedas2, 0, 0)
fragmentos = 2
elseif fragmentos == 3 then
love.graphics.draw(tragamonedas3, 0, 0)
elseif fragmentos == 4 then
love.graphics.draw(tragamonedas4, 0, 0)
elseif fragmentos == 5 then
love.graphics.draw(tragamonedas5, 0, 0)
elseif fragmentos == 6 then
love.graphics.draw(tragamonedas6, 0, 0)
elseif fragmentos == 7 then
love.graphics.draw(tragamonedas7, 0, 0)
elseif fragmentos == 8 then
love.graphics.draw(tragamonedas8, 0, 0)
elseif fragmentos == 9 then
love.graphics.draw(tragamonedas9, 0, 0)
elseif fragmentos == 10 then
love.graphics.draw(tragamonedas10, 0, 0)
elseif fragmentos == 11 then
love.graphics.draw(tragamonedas11, 0, 0)
elseif fragmentos == 12 then
love.graphics.draw(tragamonedas12, 0, 0)
elseif fragmentos == 13 then
love.graphics.draw(tragamonedas13, 0, 0)
elseif fragmentos == 14 then
love.graphics.draw(tragamonedas14, 0, 0)
elseif fragmentos == 15 then
love.graphics.draw(tragamonedas15, 0, 0)
elseif fragmentos == 16 then
love.graphics.draw(tragamonedas16, 0, 0)
elseif fragmentos == 17 then
love.graphics.draw(tragamonedas17, 0, 0)
elseif fragmentos == 18 then
love.graphics.draw(tragamonedas18, 0, 0)
elseif fragmentos == 19 then
love.graphics.draw(tragamonedas19, 0, 0)
elseif fragmentos == 20 then
love.graphics.draw(tragamonedas20, 0, 0)
elseif fragmentos == 21 then
love.graphics.draw(tragamonedas21, 0, 0)
elseif fragmentos == 22 then
love.graphics.draw(tragamonedas22, 0, 0)
elseif fragmentos == 23 then
love.graphics.draw(tragamonedas23, 0, 0)
elseif fragmentos == 24 then
love.graphics.draw(tragamonedas24, 0, 0)
fragmentos = 0
end
end
end
end
My problem is that it has to repeat the animation 6 times, but it does it infinitely, or when I manage to make it stop it only does it once and it does it too fast. Could anyone help me please. Thanks