How You Use A Variable In A .x Statement

Hi, 

 

I have look for a while but had no luck and was wondering if anyone could help.

 

I have 4 images and some code to work out which in on the screen now which is due next etc.

 

They are numbered 1 thru 4.

 

my variable is currentImageNumber

 

local newRight = Image1.x + 960

 

what i want to right is as shown above but instead of using Image1.x i want it to be Image then the currentImageNumber .x

 

so it could be Image1.x or Image2.x etc.

 

so far i have not managed to work out how to do that but any help would be appreciated.

 

Thanks

 

Mike

This is the use of a table.

[lua]

Image = {}

Image[1] = display.newImageRect(…)

Image[2] = display.newImageRect(…) – put in the right parameters to load the image.

– etc.

 

for i = 1, 4 do

     newRight = Image[i].x + 960

end

[/lua]

thank alot

 

so if I put them in a table instead of saying i = 1 to 4

 

could i make 2 variables say e.g currentimage and nextimage

 

so i could say

 

image[currentimage].x … ect

image[nextimage].x…ect

 

thanks again

This is the use of a table.

[lua]

Image = {}

Image[1] = display.newImageRect(…)

Image[2] = display.newImageRect(…) – put in the right parameters to load the image.

– etc.

 

for i = 1, 4 do

     newRight = Image[i].x + 960

end

[/lua]

thank alot

 

so if I put them in a table instead of saying i = 1 to 4

 

could i make 2 variables say e.g currentimage and nextimage

 

so i could say

 

image[currentimage].x … ect

image[nextimage].x…ect

 

thanks again