Hi,
I need some help here…
Lets say i have 5 buttons with number on it if i have one handler how can i identify which button was pressed, can you please post some code
Best regards
Juan
Hi,
I need some help here…
Lets say i have 5 buttons with number on it if i have one handler how can i identify which button was pressed, can you please post some code
Best regards
Juan
[lua]
local buttonText = { 1 , 2 , 3 , 4 , 5 }
local touchButton = function (event)
local obj = event.target
local bid = obj.id
if event.phase == “ended” then
print (“Button " …b id. .” was pressed")
end
end
for a = 1 , #buttonText, 1 do
local g = display.newGroup()
local i = display.newRect(g, 0 , 0 , 100 , 40 )
local t = display.newText(g, buttonText[a], 0 , 0 , native.systemFont, 10 )
g.x = 160
g.y = a * 48
g:addEventListener(“touch”,touchButton)
g.id = a
end
[/lua]
Thank you very much!!!
[lua]
local buttonText = { 1 , 2 , 3 , 4 , 5 }
local touchButton = function (event)
local obj = event.target
local bid = obj.id
if event.phase == “ended” then
print (“Button " …b id. .” was pressed")
end
end
for a = 1 , #buttonText, 1 do
local g = display.newGroup()
local i = display.newRect(g, 0 , 0 , 100 , 40 )
local t = display.newText(g, buttonText[a], 0 , 0 , native.systemFont, 10 )
g.x = 160
g.y = a * 48
g:addEventListener(“touch”,touchButton)
g.id = a
end
[/lua]
Thank you very much!!!