Subdirectories for images

Hi,
If all the images are in the same directory as the main.lua file, then they work, now if I would want to put them separate for each level, and organise them as

level1
----image1.png
----image2.png
level2
----image1.png
----image2.png

would display.newImage("level1/image1.png") work?

It is not for me, so just wondering what is the alternative?

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3529 reply_id: 303529[/import]

as far as i know everything needs to be in one directory

use

level1_image1.png
level1_image2.png
level2_image1.png

etc
[import]uid: 6645 topic_id: 3529 reply_id: 10670[/import]

Yes you can put images in subdirectory’s.

Works for me [import]uid: 6981 topic_id: 3529 reply_id: 10672[/import]

putting my images in “images/” works just fine for me too. [import]uid: 11024 topic_id: 3529 reply_id: 10688[/import]

You might want to build for device and test directories on the device. If I recall from previous posts, the corona simulator understands directories, but the device will fail when trying to load an image.

Have not tried this personally though. [import]uid: 8541 topic_id: 3529 reply_id: 10694[/import]

I’m testing just fine on my iPhone4 as far as images with directories go. The only thing not working on the device for me is playEventSound. [import]uid: 11024 topic_id: 3529 reply_id: 10697[/import]

Hi,
I tried with lev1/image1.png only to get an error, so does it work only with the images name? (haven’t tried, must try before asking)

Thanks, need to look into that

 local image1 = display.newImage(level .. "\_image1.png") 

is not exactly what I want to maintain in my code, and how many directories deep would this work? in the sense,

Level1
----Villians
| ----Char1.png
| ----Char2.png
----Backdrops
----Scene1.png
----Scene2.png
----Animated
-----Sun.png
-----Stars.png
-----Birds.png
Level2
----Villians
| ----Char1.png
| ----Char2.png
----Backdrops
----Scene1.png
----Scene2.png
----Animated
-----Sun.png
-----Stars.png
-----Birds.png

and so on…
cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3529 reply_id: 10711[/import]

i read something about android having problems with images with the same name (ignoring the extension)
in this case though the images were:

something.jpg
something.png

the advice was to use something_jpg.jpg and something_png.png so that they are different without the file extension

this may be the case when using images in subfolders where the images have the same name. I couldnt say for sure [import]uid: 6645 topic_id: 3529 reply_id: 10713[/import]

i dont know how deep you can go because I am only going one level atm, but I have no problems on all iOS devices putting images in directories. including sprite sheets, however the accompanying lua file needs to be in the main directory.

local mainMenuSheet = sprite.newSpriteSheetFromData(“images/menu-mainSheet.png”, require(“menu-mainSheet”).getSpriteSheetData())

local titleSign = display.newImage(“images/title-sign.png”,0,0)

Both work fine.

-Eric [import]uid: 9187 topic_id: 3529 reply_id: 10714[/import]

Does your level variable include the forward slash? [import]uid: 11024 topic_id: 3529 reply_id: 10720[/import]

Hi Everybody,
yes I did use the forward slash. I will try again, with a blank project just to test this first. I am also getting a 7" Android 2.1/2.2 tablet for testing on a physical device, I will let you know.

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3529 reply_id: 10725[/import]

Hello all,

Any news about this ?

I would like to use 1 folder structure like:

-> bacgrounds:

  • loading.jpg
  • level1.jpg
  • level2.jpg

will this work on android also ?
from previous posts I can see that it works on ios ok.? [import]uid: 73847 topic_id: 3529 reply_id: 48994[/import]

/media/images/ui/panel/cannon.png
Works fine on android. [import]uid: 58303 topic_id: 3529 reply_id: 49003[/import]