Page 1 of 1

Question about loading multiple Images.

Posted: Fri Jan 03, 2014 10:30 am
by Hammabro
Let me start off by saying that I'm new to Love and Lua in general.

What I'm trying to do is simply find a way to load multiple images without having to use love.graphics.newImage multiple times. All images would be numbered 1-100. I'm posting this is frustration because this seems so simple and my attempts at finding an answer searching have been futile. If you could help me I would greatly appreciate it!

Re: Question about loading multiple Images.

Posted: Fri Jan 03, 2014 11:11 am
by mickeyjm
Try storing the images in a table and loading them with a loop. For example:

Code: Select all

local images = {}
function love.load()
  for i=1,100 do
    images[i] = love.graphics.newImage("IMAGENAME"..i..".png")
  end
end
This will load 100 images named IMAGENAME1.png through to IMAGENAME100.png, you can change the name an extension of the image to match the images you want to load

Re: Question about loading multiple Images.

Posted: Sat Jan 04, 2014 9:59 am
by Hammabro
Thank you very much! this was exactly what I was looking for.

Re: Question about loading multiple Images.

Posted: Sat Jan 04, 2014 12:10 pm
by CRxTRDude
Offtracking though, you might want to post those kinds of questions to support. The question's more appropritate there. Not that I'm against you, it's just more suitable there. :)


*If you get offended, no offense.