Hi,
Is there anyway to create animation from a sequence of single images rather than spritesheet?
Thanks in advance.
Regards.
[SOLVED]Animation!
[SOLVED]Animation!
Last edited by Arclord on Thu Nov 03, 2011 7:39 pm, edited 1 time in total.
Re: Animation!
Sure. Insted of cycling through an array of quads, shift through an array of images. Adapting from a spritesheet model should be quite simple.
Re: Animation!
Just store the images you want to use in a table, and have a constant that refers to the currently displayed image. Something like this
Code: Select all
images = {}
images[1] = love.newImage(...) --add lots of images
currImage = 1 --stores the number of the current image
function draw()
love.graphics.draw(images(currImage),...)
end
function cycle()
--cycles through the different animations one step, call this every once in a while
currImage = currImage + 1
if currImage > #images then
currImage = 1
end
end
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: Animation!
It says - attempt to call table value.
Thanks for the reply.
Regards.
Thanks for the reply.
Regards.
Re: Animation!
Haha, too much MATLAB for me recently.Arclord wrote:It says - attempt to call table value.
Thanks for the reply.
Regards.
Code: Select all
images = {}
images[1] = love.newImage(...) --add lots of images
currImage = 1 --stores the number of the current image
function draw()
love.graphics.draw(images[currImage],...)
end
function cycle()
--cycles through the different animations one step, call this every once in a while
currImage = currImage + 1
if currImage > #images then
currImage = 1
end
end
Also, not to be a jerk, but you break the forum rules. When you ask for help, make it easier for us to help you. Most important of all, post .love-files. Saying "I get this error" doesn't make it easy to help you.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: Animation!
Sorry, I forgot to post the love file. Here it is.
EDIT: attachment removed.
Thanks
EDIT: attachment removed.
Thanks
Last edited by Arclord on Thu Nov 03, 2011 7:39 pm, edited 1 time in total.
Re: Animation!
Picking the i:th value of a table is table, not table(i) like I wrote first.Arclord wrote:Sorry, I forgot to post the love file. Here it is.
Thanks
Also, you need to call cycle every once in a while.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: Animation!
Yes. got it. Thanks T-Bone for your time and help.
Regards.
Regards.
Who is online
Users browsing this forum: Bing [Bot] and 12 guests