双击Cocos2d Android JAVA

双击Cocos2d Android JAVA,java,android,cocos2d-iphone,sequence,Java,Android,Cocos2d Iphone,Sequence,试图在Android(Cocos2d框架)中检测doubletap。我做错了什么 在这方面,我有: public boolean ccTouchesEnded(MotionEvent event) { touchTapCount++; Lg("Tapcount : " + touchTapCount); if (touchTapCount == 1) { Lg("We're in the 1 thingie!"); CCDelayTime

试图在Android(Cocos2d框架)中检测doubletap。我做错了什么

在这方面,我有:

public boolean ccTouchesEnded(MotionEvent event) {

    touchTapCount++;
    Lg("Tapcount : " + touchTapCount);
    if (touchTapCount == 1) {
        Lg("We're in the 1 thingie!");
        CCDelayTime delayaction = CCDelayTime.action(0.2f);
        CCCallFunc callSelectorAction = CCCallFunc.action(this, "dtreset");
        CCSequence a = CCSequence.actions(delayaction,(CCFiniteTimeAction) callSelectorAction);
        this.runAction(a);
    } else {
        if (touchTapCount ==2){
            Lg("Oh yeah we got double tap!");
        }
    }
我找到了重置者:

public void dtreset(Object Sender){
    Lg("Resetted the TouchTapCount");
    touchTapCount = 0;
}

我的输出表明序列根本没有运行。。因此,只需添加计数,200毫秒后没有重置…:(

作为解决方案,我决定使用android自己的处理程序类

public boolean ccTouchesEnded(MotionEvent event) {

    touchTapCount++;
    Lg("Tapcount : " + touchTapCount);
    if (touchTapCount == 1) {
        // Very important bit of code..
        // First, we define a Handler and a Runnable to go with it..
        Handler handler = new Handler(Looper.getMainLooper());
        final Runnable r = new Runnable() {
            public void run() {
                // In the runnable, we set the touchTapCount back to 0..
                touchTapCount = 0;
            }
        };
        // Now, execute this handler with a delay of 200ms..
        handler.postDelayed(r, 200);

    } else {
        if (touchTapCount == 2){
            wasdoubletapped = true;
            verifySelectorTypeBeforeRotate(cC, cR, SELECTOR_CROSS);
        }

因此,它的作用是:在第一次点击200毫秒后,通过计算点击次数并将计数重置为零来检测双击。

可能在
事件中嵌入了一个tapcount属性。
。在touchsbeging中捕捉它。