I am coming from a python background so I keep trying to work in a pythonic way. That could be my issue, let me know.
My issue at hand is this, I need to make 15 display.newImage calls to load in 15 specific 512x512 images. The paths to these images is generated by a pair of for loops that operate on a pair of arrays. Something like this {1,2,3,4,5} and {“a”,“b”,“c”} which get me 1a,1b, ect…
The trouble I am running into is that while I can get Lua to add each new display.newImage to a single array use table.insert() if I do this in the main.lua I get some results, if I do it in a module and pass it back then I don’t get anything visual to display.
I have also not been able to add them to a two dimensional array. Ideally I could use two string keyboards as the ids. In python this would be a Dictionary with Dictionaries inside it.
I could call it like this:
foo[‘bar’][‘bob’]
Where foo is my table/dict and ‘bar’ and ‘bob’ are string indexes.
When I try and make a structure like this in lua and then latter try and call them things like .isVisable return as nil
However if I make them a 1d array with just int indexes and use table.insert() then .isVisable works.
The final app will only display 1 of the 15 images at a time, it will need to switch between them quickly based on user input from the accelerometer and touch.
I’m trying to port this from GameSalad where I made it in about 3 hours.
I had planned to not use a sprite sheet due to the number of images and size that I am loading into memory.
I had originally made the function that generated all display objects in a separate lua file then had it just return the array. The problem is none of the images would ever display, once the function just returned a list of paths and I did all my display.newImage in main.lua the graphics could appear. Do Lua tables contain pointers, copies, instances, or references of objects that you add to them? I wanted to pass back the table and 15 images from the module to the main code.
So after reading all that, am I going about this in the right method for Corona? Is there a better structure to building this type of app here?
Ideas I have toyed with:
* Making n DisplayGroups and using them as dimensions
* Creating a lookup between the int index and my 2d system
* creating a helper function that just takes in what should be on right now
* having a global variable for each of my 2 look ups and have the user input set those in separate functions , then have enterframe event turn all the right ones on and off
[import]uid: 110373 topic_id: 19364 reply_id: 319364[/import]