2016-03-26 29 views
-1

我有2個按鈕,其中之一是在另一個之上。 屏幕截圖:http://prntscr.com/akc6f7(2個按鈕)如何優先按鈕

基本上,當我點擊角落中的小按鈕(「?」)時,我也點擊了更大的按鈕。我怎樣才能確保我只點擊「?」按鈕?

此外,這些按鈕是newImageRect()

回答

0

觸摸事件將首先觸發最外面的UI元素。

return true加到「?」的末尾按鈕觸摸事件來表示觸摸已被代碼處理。

沒有return true,觸摸事件不知道它的處理,並隨後觸發對包含觸摸(優先考慮的元素最外層的元素)

function QuestionMarkTouchEvent(event) 

if event.phase == "began" then 
    -- Do some stuff 
end 

return true -- this tells the program not to fire the touch event again on elements under this. 

end 
所有元素