lua - How to utilize arrays in corona? -


i have created text array , image array. how make such when random image appears corresponding text appears? example: when image shows 9, want text displayed 9 need help.

are looking getting index of arrays in lua? i'll provide small example.

you can create array like:

local myarray = {"element_1","element_2",...,"element_n"} 

and can array element as:

print(myarray[1]) -- prints 'element_1'   (1st element) print(myarray[n]) -- prints 'element_n'   (nth element) 

so, if have 2 arrays below;

local myquestionarray = {"1","2",...,"n"} local myimagearray    = {"img_1","img_2",...,"img_n"} 

you can take question , image respect number as:

  -- number = 1   print(myquestionarray[1]);  // 1   print(myquestionarray[1]);  // img_1    -- number = n   print(myquestionarray[n]);  // n   print(myquestionarray[n]);  // img_n 

for mode details, refer: understanding lua tables in corona sdk

keep coding.......... :)


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -