Producing animations from one picture?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Lua Hal
Citizen
Posts: 58
Joined: Tue Jul 12, 2011 10:30 pm

Producing animations from one picture?

Post 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!
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Producing animations from one picture?

Post 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.
User avatar
middlerun
Citizen
Posts: 64
Joined: Tue Nov 25, 2008 4:31 am
Location: Sydney, Australia
Contact:

Re: Producing animations from one picture?

Post by middlerun »

You can do this using the AnAL library.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Producing animations from one picture?

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Producing animations from one picture?

Post 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.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 76 guests