简体   繁体   English

Corona SDK-在线上的触摸事件不起作用

[英]Corona SDK - Touch event on Line not working

I am trying to call touch Listener on line, but it is not working. 我正在尝试在线调用touch Listener,但无法正常工作。 If I try it on any other display object, it does work. 如果我在其他任何显示对象上进行尝试,都可以。

Simple Example: 简单的例子:

local function touchListener(e)
    print("removeLine")
    print("Name: " .. e.target.name)
end

Above is touch listener function. 上面是触摸监听器功能。

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 )

Added listener on line , but never works. 新增监听line ,但永远不会奏效。

local circle = display.newCircle(sceneGroup, 150, 150, 50)            
circle:setFillColor(0, 1, 0, 1)
circle.name = "circle"
circle:addEventListener( "touch", touchListener )

Added listener on circle , and works perfectly. circle上添加了侦听器,并且效果很好。

Can anyone please suggest, what I am doing wrong with line ? 谁能建议我,我在做错line吗?

A single line is a small target to try and touch. 一行是尝试触摸的小目标。 Apple suggests that 44 points is the smallest touch target. 苹果建议44点是最小的触摸目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM