We are using tables to load newImages. But is there a better way to refer to each of these images than image[1], image[2] etc?
So in this example, after loading into images{} we might want to animate or transition the image but we have to refer to each image as image[1], image[2] etc when we would like to refer to them by name e.g. bm_clr1, bm_clr2 etc.
One way of course is to manually do something like:
pix = {}
pix.bm_clr1 = image[1]; pix.bm_clr2 = image[2]; pix.bm_clr = image[3] etc.
But this way is not ideal, especially when the image list gets really long and you want to change the order or add something later.
-- Loading images local imageList = { { name="bm\_clr1", w=114, h=418, x=1944, y=209, rgb = RGB1 }, { name="bm\_clr2", w=114, h=312, x=1944, y=193, rgb = RGB2 }, { name="bm\_clr3", w=114, h=314, x=1944, y=228, rgb = RGB3 }, { name="bm\_clr4", w=114, h=312, x=1944, y=262, rgb = RGB4 }, { name="bm\_crossbnd", w=118, h=420, x=1944, y=210 }, { name="bm\_cross", w=68, h=70, x=1944, y=300 }, { name="bmclear", w=150, h=448, x=1944, y=209}, { name="txt\_engback", w=116, h=34, x=1944, y=458 }, } local image = {} for i = 1, #imageList do image[i] = display.newImageRect ( imgDir.. "mc\_"..imageList[i].name..".png", imageList[i].w, imageList[i].h ) image[i].x = imageList[i].x; image[i].y = imageList[i].y image[i].alpha = 1 image[i].name = imageList[i].name if imageList[i].rgb then image[i]:setFillColor( unpack(imageList[i].rgb) ) end end