I am building a puzzle game, detecting objects when touch. Works horizontally and diagonally but not vertically what do I miss?
function touchMe(event)
if ( event.phase == “began” ) then
event.target.xScale = 1.0
event.target.yScale = 1.0
event.target.alpha = 0.4
elseif (event.phase == “moved”) then
event.target.xScale = 1.0
event.target.yScale = 1.0
event.target.alpha = 0.4
if (alphabet[event.target.id].alreadytouched == false ) then
alphabet[event.target.id].alreadytouched = true
assembledWord = assembledWord…event.target.value
print(assembledWord)
end
elseif( event.phase == “ended”) then
event.target.alpha = 1
if(alphabet[event.target.id].alreadytouched == false ) then
alphabet[event.target.id].alreadytouched = true
end
end
end
for i = 1, 6 do
for j = 1, 6 do
local fname = nil
if(L1Map[j][i] == 0) then
str = sletter[math.random(26)]
L1Map[j][i] = str
fname = “letters/ltr_”…str…".png"
else
fname = “letters/ltr_”…L1Map[j][i]…".png"
end
alphabet[i] = newImageRectNoDimensions(fname)
alphabet[i].x = math.floor(-30 + (55 * i))
alphabet[i].y = math.floor(-10 + (35 * j))
alphabet[i].alreadytouched = false
alphabet[i].value = L1Map[j][i]
alphabet[i].id = i
alphabet[i]:addEventListener( “touch”, touchMe)
end
end