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.