How to add image into array and display
local imageTable = {} imageTable[1] = display.newImage("myimage.png")
Can I put imageTable[1] = display.newImage(“myimage.png”) into {}
yip
[lua]
local imageTable =
{
display.newImage(“myimage.png”)
}
[/lua]
further read recommendations:
http://www.coronalabs.com/blog/2011/06/21/understanding-lua-tables-in-corona-sdk/
http://docs.coronalabs.com/api/type/Table.html
http://docs.coronalabs.com/api/library/table/insert.html
local imageTable = {{"1.png"},{"2.png"},{"3.png"}}
Can I make like this and how to display ?
yes you can.
but just to be clear
-
you are creating a 2 dimensional table here, why?
-
your second dimension is carrying nothing less and nothing more than strings, not images, just the words inside “”
you could show them for example this way
[lua]
local imageTable = {{“1.png”},{“2.png”},{“3.png”}}
local myImage1 = display.newImage(imageTable[1][1])
local myImage2 = display.newImage(imageTable[1][2])
local myImage3 = display.newImage(imageTable[1][3])
[/lua]
personal opinion:
it doesnt make too much sense, its making your code more complex without giving you much of a benefit, at least i dont see one. i am unsubscribing to this thread now because most of your questions are solved by the beginners guides, the docs, the answers already provided, or the links provided here.
i wish you happy coding and success on your project,
have a nice day,
fox
local imageTable = {} imageTable[1] = display.newImage("myimage.png")
Can I put imageTable[1] = display.newImage(“myimage.png”) into {}
yip
[lua]
local imageTable =
{
display.newImage(“myimage.png”)
}
[/lua]
further read recommendations:
http://www.coronalabs.com/blog/2011/06/21/understanding-lua-tables-in-corona-sdk/
http://docs.coronalabs.com/api/type/Table.html
http://docs.coronalabs.com/api/library/table/insert.html
local imageTable = {{"1.png"},{"2.png"},{"3.png"}}
Can I make like this and how to display ?
yes you can.
but just to be clear
-
you are creating a 2 dimensional table here, why?
-
your second dimension is carrying nothing less and nothing more than strings, not images, just the words inside “”
you could show them for example this way
[lua]
local imageTable = {{“1.png”},{“2.png”},{“3.png”}}
local myImage1 = display.newImage(imageTable[1][1])
local myImage2 = display.newImage(imageTable[1][2])
local myImage3 = display.newImage(imageTable[1][3])
[/lua]
personal opinion:
it doesnt make too much sense, its making your code more complex without giving you much of a benefit, at least i dont see one. i am unsubscribing to this thread now because most of your questions are solved by the beginners guides, the docs, the answers already provided, or the links provided here.
i wish you happy coding and success on your project,
have a nice day,
fox