如何使用Corona SDK检测双指轻击?

如何检测到双指点击事件?tap 事件可告知点击次数,但无法提供有关事件中涉及的触摸数量信息。有没有办法解决这个问题?我的 Corona 应用程序启用了多点触控,模拟单指点击相当于模拟鼠标左键单击,模拟双指点击相当于模拟鼠标右键单击。

编辑

总之,我想做到以下两件事:

  1. 用我的食指单击来模拟应用程序中的左键单击。即一个触摸,一个点击。
  2. 用我的食指和中指同时点击一次来模拟应用程序中的右键单击。即同时两个触摸,一个点击。

以下是 Corona 团队在其论坛中对我的问题的回答: http://forums.coronalabs.com/topic/35037-how-to-detect-two-finger-tap-in-corona

点赞
用户1979583
用户1979583

你可以像这样做:

function object:tap( event )
    if (event.numTaps >= 2 ) then
      print( "The object was double-tapped." )
    end
end
object:addEventListener( "tap" )

有关 Corona 中对象/屏幕点击的更多详细信息,请参见这里...

继续编码...... :)

2013-05-16 10:57:35
用户1502079
用户1502079

像来自 Corona 的 Brent Sorrentino 所说的那样:你应该使用多点触控。

首先看看这个http://docs.coronalabs.com/api/event/touch/id.html

你已经可以自己做了。 以下是我的实现:

system.activate( "multitouch" )

local object = display.newImage( "ball.png" )
object.numTouches = 0

function object:touch( event )
    if event.phase == "began" then
        display.getCurrentStage():setFocus( self, event.id )

        self.numTouches = self.numTouches + 1

    elseif event.phase == "cancelled" or event.phase == "ended" then
        if self.numTouches <= 1 then
            print( "This is a Left click" )
            --call your onLeftClickFunction here
        end

        if self.numTouches == 2 then

            print( "This is a Right click" )
            --call your onRightClickFunction here
        end
        self.numTouches = 0
        display.getCurrentStage():setFocus( nil )
    end
    return true
end
object:addEventListener( "touch", object )
2013-05-17 21:08:48