Animations
Posted: Sat Apr 16, 2011 3:11 pm
How can i make simple image animations without having to use a loop to show different images at an order?
Thanks!
Thanks!
Code: Select all
love.load()
animation = {
love.graphics.load('image1.png'),
love.graphics.load('image2.png'),
love.graphics.load('image3.png')
}
frame = 1 -- loops from 1 to 3
timepassed = 0 -- how much time has passed since the last frame
end
love.update(dt)
timepassed = timepassed + dt
if timepassed >= 0.5 then
timepassed = 0
frame = frame + 1
if frame == 4 then frame = 0 end
end
end
love.draw()
love.graphics.draw(animation[frame], 100, 200)
end