When a tile is tapped, I have a event to capture this. My question is, how would I be able to access the tiles around the tile that is tapped.
Example:
Lets say tile in position [2][2] is tapped and the chipTapped function is called. This would change the alpha in tile[2][2]. How would I also change the alpha for the tile in position [2][3]?
Thanks for any help!
Warren
local function chipTapped(event)
if event.target.alpha == 1 then
event.target.alpha = .2
else
event.target.alpha = 1
end
end
for row = 1, numRows do
for col = 1, numCols do
i=i+1
if puzzle[1][i] == “” then
local chip = display.newImageRect(“images/blank.png”,20,20)
else
chip = display.newImageRect(“images/black.png”,20,20)
end
–chip.width = chipWidth – for testing only
–chip.height = chipHeight – for testing only
chip.x = xPos + col * (chipWidth + colSpace) - chipWidth/2 - colSpace
chip.y = yPos + row * (chipHeight + rowSpace) - chipHeight/2 - rowSpace
chip.gridPos = {x=col, y=row}
chip.letter = puzzle[1][i]
chip.inx = i
chip:addEventListener(“tap”, chipTapped)
end
end