不同的层科罗纳/ Lua中 [英] Different layers in Corona/Lua
问题描述
我有关于分层图像/按钮与科罗纳/ Lua的一个问题。如果我在创造一个又一个的上面的一个按钮,然后单击它,两个按钮事件被触发。我如何prevent呢?
谢谢,埃利奥特博纳维尔
编辑:这里就是我创建的按钮:
按钮1 = display.newImage(button1.png)
按钮1:的addEventListener(点击,Button1Call)按钮2 = display.newImage(button2.png)
按钮2:的addEventListener(点击,Button2Call)
从事件处理函数返回true。触摸事件不断通过听众传播,直到处理;它在这里解释道:
http://developer.anscamobile.com/content/events-and-听众#Touch_Events
请注意,该事件侦听器必须监听相同的事件。换句话说,无论是听众必须在任触摸或点击进行设置。从字面上看,昨晚我被这绊倒;我有一个按钮,听触摸,并在上面听龙头另一幅图像,并想知道为什么按钮仍然接收事件。
I've got a question about layering images/buttons with Corona/Lua. If I create one button on top of another one and then click it, both buttons' events are triggered. How do I prevent this?
Thanks, Elliot Bonneville
EDIT: Here's how I create the buttons:
button1 = display.newImage("button1.png")
button1:addEventListener("tap", Button1Call)
button2 = display.newImage("button2.png")
button2:addEventListener("tap", Button2Call)
Return true from the event handling function. Touch events keep propagating through the listeners until handled; it's explained here:
http://developer.anscamobile.com/content/events-and-listeners#Touch_Events
Note that the event listeners must be listening for the same event. In other words, both listeners must be set on either "touch" or "tap". Literally last night I was tripped up by this; I had a button listening to "touch" and another image on top listening to "tap" and was wondering why the button was still receiving events.
这篇关于不同的层科罗纳/ Lua中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!