Graphics organized in folders...am I missing something?

Just bought the Game Edition, coming over from the TorqueX world…

Never used Corona and LUA before, I come from a .NET C# background, but I like what I’m seeing.

Wondering if I’m missing something totally obvious, but I wanted to organize my PNGs and JPGs into folders in my project folder for loading. Is that at all possible? What would the “UNIXy” usage be?

In my project folder I have a folder called “Textures” and want to load “ship1.png”…

myImage2 = display.newImage( “Textures\ship1.png”,20,30)

But the debug shows that’s not reachable.

Does this fall under the wonderful world of the “walled garden” and “sandbox” stuff? Is it possible to do? I see that all the samples included have their graphics all located in the root folder of the project…
Thanks in advance guys! [import]uid: 11636 topic_id: 4035 reply_id: 304035[/import]

Hi mroberti,

Welcome to Corona! I’m a somewhat recent “convert” myself from iTorque2D; truly a shame what happened to them, and I hope they can rebuild in some respect. Torque had some simply amazing technology behind it… some of which I’m still missing, even though I’m very much enjoying Corona and I’m finding new ways to accomplish the things I did in Torque (and of course, I’m finding that Corona makes some tasks 1000 times easier than Torque ever did. :slight_smile: ).

But I digress… to answer your question, generally speaking, files and images and everything else in Corona should be placed in the root directory. I think other users have had success placing files in sub-directories, but it’s possible that will cause problems when you publish onto the actual device. I don’t want to say definitively that you can’t use sub-directories, but my own opinion is that it’s better not to. This is definitely a change coming from Torque where everything was so neatly organized, but I can accept it… just takes some adjustment.

Best of luck; nice to see some other Torque refugees here.

Brent
[import]uid: 9747 topic_id: 4035 reply_id: 12330[/import]

your slash is the wrong way round

you want

[lua]myImage2 = display.newImage( “Textures/ship1.png”,20,30)[/lua]
[import]uid: 6645 topic_id: 4035 reply_id: 12338[/import]

Why do you think there would be a problem using sub folders? They work fine for me, I have /images and /sound sub folders, it’s tidier. [import]uid: 9371 topic_id: 4035 reply_id: 12343[/import]

Excellent! I knew it was something simple! Glad a backwards slash was all the issue was!

Thanks for the help and insight folks! [import]uid: 11636 topic_id: 4035 reply_id: 12363[/import]

Why do you think there would be a problem using sub folders? They work fine for me, I have /images and /sound sub folders, it’s tidier.

I recall some discussions (including some with input from Ansca staff) that “hinted” that sub-directories might cause problems on the actual devices, after compilation. While sub-directories work fine in the Corona Simulator, have they been fully tested on both iOS and Android? This is where the confusion lies, so until we get a definitive answer, or somebody can confirm a full test report on end devices, I’m going to stay with the root directory method… although I would definitely prefer to organize them into folders, since the root directory will be a terrible mess once I create a full library of images and sounds. [import]uid: 9747 topic_id: 4035 reply_id: 12373[/import]

Hmmmm, well I deployed to my recently updated iPad (4.2.1) and all seems well using the subfolder method. We’ll see if something 'splodes down the road! Should be an exciting ride! :slight_smile: [import]uid: 11636 topic_id: 4035 reply_id: 12374[/import]

Also note that presently, spritesheets with data currently must operate out of the root folder. Sprite sheets independent of data have no problem. [import]uid: 11024 topic_id: 4035 reply_id: 12377[/import]

Perhaps someone from Ansca wants to weigh in here. The documentation does say that all project assets have to be in a single directory for device builds. [import]uid: 1560 topic_id: 4035 reply_id: 12419[/import]

it says that because subfolders are not guaranteed to work

eg I believe android caches files based on the filename without extension

if you have

level1/blah.png
level2/blah.png

i believe it’s going to break, as it just sees it as “blah”

I don’t know this for sure but I know when you have

something.ogg
something.mp3

it causes an error

you have to do

something_ogg.ogg
something_mp3.mp3

in order for it to see the files differently without error

[import]uid: 6645 topic_id: 4035 reply_id: 12446[/import]

My understanding is that .lua files CANNOT be in subfolders but graphic and sound files CAN be. [import]uid: 8353 topic_id: 4035 reply_id: 15334[/import]

“…I deployed to my recently updated iPad (4.2.1) and all seems well using the subfolder method…”

So that’s all that matters to me. Yes, it works with sub folders!

PLUS the point is moot now that I got Corona Project Manager, it does all that FOR me!! :slight_smile:

Thanks for the help!

-Mario [import]uid: 11636 topic_id: 4035 reply_id: 15346[/import]

spritesheets with data currently must operate out of the root folder

That’s not exactly true because of, well, this other reply:

My understanding is that .lua files CANNOT be in subfolders but graphic and sound files CAN be.

Basically, in Corona code files always have to be in the root folder while other resources can be in sub-folders. Since the data files for spritesheets are code files, those data files must be in the root but the sprite images themselves can be in sub-folders.

This enables a pretty neat organization of files actually: only code in the root folder, while png files go in the “graphics” directory and sound files go in the “audio” directory. [import]uid: 12108 topic_id: 4035 reply_id: 15362[/import]

I agree with jhocking, at least that’s my experience, everything but LUA files can be put in subfolder.
[import]uid: 11334 topic_id: 4035 reply_id: 15561[/import]