touch.tapCount

Hi,

I’m trying to get a double tap on a GUI on the iPhone, what I want is a single tap to zoom in and a double tap to change the view, but using the below code it always print out “single tap” before going to “double tap” any help would be great.

function Update(){
    	
    for (var touch : Touch in Input.touches){
    
        if (gui03.HitTest (touch.position)){
    
            if(touch.tapCount == 2){
                print("double tap");
                return;
            }else if(touch.tapCount == 1){
                print("single tap");
            }
        }
    }
}

Well, before the system knows you have touched twice, it has seen the single tap, so lets you know the screen has been touched once. I’ve never seen tapCount used. I am sure there are hordes of developers who have used it. I think what I’d do is start a timer when the single tap comes in. If the double tap arrives, then process that. Otherwise, if the timer exceeds something like 0.5 seconds assume that a second tap is not coming, so process the single tap.