2012-01-09 58 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"); 

    }