2012-01-09 108 views

回答

0

使用布尔值打开/关闭您的触摸代码。

if (touchEnabled) 
{ 
    // do touch code 
} 
else 
{ 
    // not … 
} 

别的地方,暂时禁用触控:

// accept no touches from now on 
touchEnabled = false; 

我离开重新启用触摸取决于你。

1

您也可以设置自定义定时器:

static Integer time = 100; 

和倒计时当你需要它:

time--; 
... 
if (time <= 0) { 
    setTouchEnabled = false; 
//you can also reset time here: time = 100; 
} else { 
    setTouchEnabled = true; 
} 
0

定义一个时间变量

static float time; 

下面写代码时,你想要禁用触摸屏

this.schedule("touchdiablefor5sec",1f); 

现在写以下方法

public void touchdiablefor5sec(float dt) { 
     //first disable screen touch 
     this.setIsTouchEnabled(false); 
     time= time+1; 
     // if 5 second done then enable touch 
     if(time==5) 
     { 
      this.setIsTouchEnabled(true); 
      //unschedule the touchdiablefor5sec scheduler 
      this.unschedule("touchdiablefor5sec"); 
     } 
    } 
0

可以禁用触摸和呼叫用时间5秒的调度方法

setIsTouchEnabled(false); 
schedule("enableTouchAfter5sec",5f);//5f is the duration after that method calls 

和enableTouchAfter5sec方法使触摸

public void enableTouchAfter5sec(float dt) { 
     setIsTouchEnabled(true); 
     unschedule("enableTouchAfter5sec"); 

    }