1

Cocos2dの画面でタッチを無効にしたい。タッチを 4 ~ 5 秒間無効にしたいのですが、どなたか助けてください。ありがとう

4

4 に答える 4

1

また、カスタムタイマーを設定することもできます。

static Integer time = 100;

必要なときにカウントダウンします。

time--;
...
if (time <= 0) {
    setTouchEnabled = false;
//you can also reset time here: time = 100;
} else {
    setTouchEnabled = true;
}
于 2012-03-02T22:32:51.160 に答える
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");

    }
于 2012-12-27T14:43:45.443 に答える
0

1 つの時間変数を定義する

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");
        }   
    }
于 2012-08-03T05:47:01.750 に答える
0

ブール値を使用して、タッチ コードのオン/オフを切り替えます。

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

別の場所で、タッチを一時的に無効にします。

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

タッチを再度有効にするのはあなた次第です。

于 2012-01-11T21:19:03.017 に答える