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

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

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

在其他地方,暂时禁用触摸:

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

我将重新启用触摸功能留给您。

于 2012-01-11T21:19:03.017 回答
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

定义一个时间变量

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 回答