Problems playing animation
Posted: Fri Jan 15, 2016 4:16 pm
Hi guys, pretty new to game development and very new to Love/Lua (started Wednesday) and I'm having an issue playing an animation I've created.
My animation is in a 5x3 spritesheet with each sprite having dimensions of 96x96. Here is a function I created to return each sprite in an array of quads:
And here's my code for playing the animation:
At the moment the animation is only implemented for when the player dies, but the animation seems to only display one frame.
I've attached my .love file so you can compile & see what I mean or have a pick through the rest of my code if you wish. Any help would be greatly appreciated, thank you.
My animation is in a 5x3 spritesheet with each sprite having dimensions of 96x96. Here is a function I created to return each sprite in an array of quads:
Code: Select all
function Animation:CreateQuads(spriteWidth, spriteHeight, rows, columns, img)
frame = 1
local Animation = {}
xPos = 0
yPos = 0
for _ = 1,rows do
for __ = 1,columns do
Animation[frame] = love.graphics.newQuad(xPos, yPos, spriteWidth, spriteHeight, img:getWidth(), img:getHeight())
xPos = xPos + spriteWidth
frame = frame + 1
end
xPos = 0
yPos = yPos + spriteHeight
end
return Animation
end
Code: Select all
function Animation:PlayAnimation(animationArray, x, y, img)
for frame = 1, #animationArray do
love.graphics.draw(img, animationArray[frame], x, y)
end
end
I've attached my .love file so you can compile & see what I mean or have a pick through the rest of my code if you wish. Any help would be greatly appreciated, thank you.