Hi All,
I am unable to pass a variable into my listener function for a UI button. I’m trying to process the touch events from multiple buttons with the same listener function.
Here’s my code.
[lua]local onSitBtnTouch = function(event)
if event.phase == ‘release’ then
audio.play( tapSound )
print("event.target.pos "…event.target.pos)
end
end
local sitBtn = ui.newButton{
defaultSrc = “images/sit_button.png”,
defaultX = 109,
defaultY = 49,
overSrc = “images/sit_button_over.png”,
overX = 109,
overY = 49,
onEvent = onSitBtnTouch
}
sitBtn:setReferencePoint(display.TopLeftReferencePoint)
playerInfoGroups[curPos]:insert(sitBtn)
sitBtn.x = 0
sitBtn.y = 0
sitBtn.alpha = 1
sitBtn.pos = curPos[/lua]
Why is event.target.pos is always nil?
Thanks.
Nathan.
[import]uid: 23864 topic_id: 9213 reply_id: 309213[/import]