我正在使用AndEngine捕获onSceneTouchEvent事件。

我想做的是不允许它双击屏幕来捕获用户。

无论如何,有没有检测到双击或禁用它们的功能?

谢谢

最佳答案

编辑:看了一些之后,我认为这可能更适合您:

// in an onUpdate method

onUpdate(float secondsElapsed){

if(touched){
if(seconds > 2){
doSomething();
touched = false;
seconds = 0;
} else{
seconds += secondsElapsed;
}
}

}

来自:http://www.andengine.org/forums/gles1/delay-in-touchevent-t6087.html

基于上面的评论,我确定您也可以使用SystemClock通过以下内容来修饰某些内容。

您可以通过添加延迟来摆脱困境,类似于以下内容:
public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            if(firstTap){
                thisTime = SystemClock.uptimeMillis();
                firstTap = false;
            }else{
                prevTime = thisTime;
                thisTime = SystemClock.uptimeMillis();

                //Check that thisTime is greater than prevTime
                //just incase system clock reset to zero
                if(thisTime > prevTime){

                    //Check if times are within our max delay
                    if((thisTime - prevTime) <= DOUBLE_CLICK_MAX_DELAY){

                        //We have detected a double tap!
                        Toast.makeText(DoubleTapActivity.this, "DOUBLE TAP DETECTED!!!", Toast.LENGTH_LONG).show();
                        //PUT YOUR LOGIC HERE!!!!

                    }else{
                        //Otherwise Reset firstTap
                        firstTap = true;
                    }
                }else{
                    firstTap = true;
                }
            }
            return false;
        }

取自OnTap listener implementation

07-24 09:44
查看更多