Page 1 of 1

Producing animations from one picture?

Posted: Fri Aug 26, 2011 1:41 am
by Lua Hal

Code: Select all

function love.load()
runningbunny=love.image.newImageData("NPCs\/BunnyRunning.png")
frames={}
for i = 1,runningbunny:getWidth()/32 do
frames[i]=love.image.newImageData(32,32):paste(runningbunny,0,0,(i-1)*32,0,32,32)
end
end
function love.draw()
for i = 1,#frames do
love.graphics.draw(frames[i],0,0)
love.graphics.print(i,0,32)
love.timer.sleep(10)
end
love.timer.sleep(10)
end
Nothing happens to the screen...

I want it to split an image into 32x32 pictures. on the X axis only, and then animate them in a loop.

Thanks!

Re: Producing animations from one picture?

Posted: Fri Aug 26, 2011 2:36 am
by bmelts
You can't draw ImageData directly, you need to create an Image from it first.

That said, you'd be much better served to use Quads to handle your animation.

Re: Producing animations from one picture?

Posted: Sat Aug 27, 2011 7:03 am
by middlerun
You can do this using the AnAL library.

Re: Producing animations from one picture?

Posted: Sat Aug 27, 2011 10:58 am
by T-Bone
I never understood the need for the AnAL library. Letting each game object store the quads it needs in a table, and simply have it draw the quad you want at every given time, is really simple. An automated way of creating the quads you want from any picture is also quite trivial.

Re: Producing animations from one picture?

Posted: Sat Aug 27, 2011 6:32 pm
by Robin
T-Bone wrote:I never understood the need for the AnAL library.
There's no need for it, but it's functionality used to be a core feature of LÖVE and some people miss it.