Dear master,
i have my program with one background & one image
-----------------------------------------------------------------------------
-- my background
dObjStickBoard = display.newImage('iphone\_bg\_hr.png')
dObjStickBoard:setReferencePoint(display.TopLeftReferencePoint)
dObjStickBoard.x, dObjStickBoard.y = 0, 0
dObjStickBoard.alpha = 0.5
-- my button
dObjConfig = sprtGen:grabSprite('ico-setting', true)
dObjConfig:setReferencePoint(display.TopLeftReferencePoint)
dObjConfig.x, dObjConfig.y= 10, 522
-- event
local function onEventConfig(event)
local t = event.target
if event.phase == 'began' then
display.getCurrentStage():setFocus( t )
end
if event.phase == 'ended' then
print('config clicked')
end
if event.phase == 'ended' or event.phase == 'cancelled' then
display.getCurrentStage():setFocus(nil)
end
end
local function onEventStickBoard(event)
local t = event.target
if event.phase == 'began' then
display.getCurrentStage():setFocus( t )
end
if event.phase == 'ended' then
print('stick board clicked')
end
if event.phase == 'ended' or event.phase == 'cancelled' then
display.getCurrentStage():setFocus(nil)
end
end
dObjStickBoard:addEventListener('touch', onEventStickBoard)
dObjConfig:addEventListener('touch', onEventConfig)
with code above, it always show ‘stick board clicked’ message in Terminal regardless i clicked on background or button. Is there a way to rectify this? i need the button to fire when button is clicked, and background event to fire only when background is clicked.
Thanks for the pointers [import]uid: 10373 topic_id: 25776 reply_id: 325776[/import]
[import]uid: 52491 topic_id: 25776 reply_id: 104244[/import]