Question about loading multiple Images.

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Hammabro
Prole
Posts: 2
Joined: Fri Jan 03, 2014 9:41 am

Question about loading multiple Images.

Post 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!
User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

Re: Question about loading multiple Images.

Post 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
Your screen is very zoomed in...
Hammabro
Prole
Posts: 2
Joined: Fri Jan 03, 2014 9:41 am

Re: Question about loading multiple Images.

Post by Hammabro »

Thank you very much! this was exactly what I was looking for.
User avatar
CRxTRDude
Prole
Posts: 41
Joined: Sun Dec 15, 2013 3:03 am
Location: Some island in the archipelago

Re: Question about loading multiple Images.

Post 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.
~ CRxTRDude || Will be out of touch for a wee longer than expected. Will keep in touch with soon enough. Sorry bout that.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest