Question

I am capturing the event of onSceneTouchEvent using AndEngine.

What i want to do is not allow it to capture the user double tapping the screen.

Is there anyway to detect double taps or disable them?

Thanks

Was it helpful?

Solution

EDIT: After looking around some more, I think this may better suit you:

// in an onUpdate method

onUpdate(float secondsElapsed){

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

}

Taken from: http://www.andengine.org/forums/gles1/delay-in-touchevent-t6087.html

Based on the comment above, I'm sure you can finagle something with the following too, using SystemClock.

You can get away with adding a delay, something similar to this:

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;
        }

Taken from OnTap listener implementation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top