【发布时间】:2015-09-10 13:39:56
【问题描述】:
我正在尝试在线调用触摸侦听器,但它不起作用。如果我在任何其他显示对象上尝试它,它确实有效。
简单示例:
local function touchListener(e)
print("removeLine")
print("Name: " .. e.target.name)
end
以上是触摸监听功能。
local line = display.newLine(sceneGroup, 0, 0, 100, 100)
line:setStrokeColor(1, 0, 0, 1)
line.strokeWidth = 10
line.name = 'line'
line:addEventListener( "touch", touchListener )
在line 上添加了侦听器,但始终无法正常工作。
local circle = display.newCircle(sceneGroup, 150, 150, 50)
circle:setFillColor(0, 1, 0, 1)
circle.name = "circle"
circle:addEventListener( "touch", touchListener )
在circle 上添加了监听器,并且运行良好。
谁能建议,我在line 做错了什么?
【问题讨论】:
-
目前 display.newLine() 对象不支持触摸/点击事件。 docs.coronalabs.com/api/library/display/newLine.html
-
@kumar 感谢您的评论。这个问题有什么可能的解决方案吗?
-
我觉得,你可以创建一个矩形而不是线?告诉我你为什么需要一条线?
标签: lua event-handling touch coronasdk