Adding eventListener to the images on the table

local bgimage=display.newImageRect(“images/black.png”, 360, 570)

bgimage.x = display.contentCenterX

bgimage.y = display.contentCenterY

local pattern={

{0,1,1,1,1,1,1},

{0,1,0,0,1,0,0},

{0,1,0,0,1,0,0},

{0,1,0,0,1,0,0},

{0,1,0,0,0,0,0},

{0,1,0,0,0,0,0},

{0,1,0,0,0,0,0},

{0,1,0,0,0,0,0},

{0,1,0,0,0,0,0}}

function pattern1()

for row = 1, 8 do

for col = 1, 9 do

local image = display.newImageRect(“images/white.png”, 22,21)

image.x=math.floor(-10 + (31.3 * row))

image.y=math.floor(-10 + (35 * col))

local tf = display.newText(’’, 0, 0, ‘Arial’, 19)

tf:setTextColor(0, 0, 0)

tf.width = 22

tf.height = 21

tf.x = math.floor(-10 + (31.3 * row))

tf.y = math.floor(-10 + (35 * col))

– Change 0’s to Random Letters 

if(pattern[col][row] == 0) then

image:removeSelf()

image=nil

else

tf.text=“0”

end

end

end

end

pattern1()

There’s no question here and you should use the code markup button.

what is a code markup button? Sorry. Im new here.

@MajinZepar, The code markup button is <> in blue.

@darkseekers,

Please write the following:

A question: The title is not enough. What are you looking to achieve?

The problem: What error messages did you get to the console? How did you expect your code supposed to respond compared to how it actually responded?

Debugging: What have you tried to resolve the problem?

Remember, the more you help us, the more we can and will want to help you.

You want to add event listeners to each of the images in the table, that’s simple. Just place the addEventListener function in the for loop area where you create the image.

There’s no question here and you should use the code markup button.

what is a code markup button? Sorry. Im new here.

@MajinZepar, The code markup button is <> in blue.

@darkseekers,

Please write the following:

A question: The title is not enough. What are you looking to achieve?

The problem: What error messages did you get to the console? How did you expect your code supposed to respond compared to how it actually responded?

Debugging: What have you tried to resolve the problem?

Remember, the more you help us, the more we can and will want to help you.

You want to add event listeners to each of the images in the table, that’s simple. Just place the addEventListener function in the for loop area where you create the image.