I dont know if its still a “New User” doubt, but Im tryibg do something and I dont know how.
Explaining:
I build a function that initialize all buttons in my game. It is a table with all buttons like tbl = {{"","",""},{"","",""},{"","",""}}.
So, this function initialize all buttons, with display.newImg, x and y positions. You can see part of my code in this another topic in Corona Forum: http://developer.anscamobile.com/forum/2011/08/04/tables-and-objects
I decided to initialize ALL function inside the same for statement and I did this:
[lua]init_btn = function ()
for l = 1, 3 do
for c = 1, 3 do
tabela[l][c] = display.newImage(“image/botao.png”)
tabela[l][c].x = ((background.width / 3) * c) - (tabela[l][c].width /2) - 6
tabela[l][c].y = 60 + (100 * l)
local onTapBut = function ( event )
if event.phase == “ended” then
local jogador = display.newImage(“image/o.png”)
jogador.x = (tabela[l][c].x)
jogador.y = (tabela[l][c].y)
localGroup:insert (jogador)
–removeEventListener( “touch”, onTapBut )
end
end
tabela[l][c]:addEventListener( “touch”, onTapBut )
localGroup:insert (tabela[l][c])
print(“tabela: l c:”, l, c)
end
end
end[/lua]
My problem is: This event (onTapBut) works well. But I need, after using this just one time, to remove it. And I dont know how to do this. This event is still working and my program is not working well because of it.
Ideas? I need to do Something:removeEventListener, but if I use table[l][c] as I did before, Corona seem a error and I still not identify. [import]uid: 9133 topic_id: 13316 reply_id: 313316[/import]