Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocos2d android禁用触摸_Android_Cocos2d Android - Fatal编程技术网

Cocos2d android禁用触摸

Cocos2d android禁用触摸,android,cocos2d-android,Android,Cocos2d Android,我想禁用Cocos2d屏幕中的触摸功能。我要触摸禁用4-5秒,有人帮我吗。 谢谢使用布尔值来打开/关闭触摸代码 if (touchEnabled) { // do touch code } else { // not … } 在其他地方,暂时禁用触摸: // accept no touches from now on touchEnabled = false; 我让您重新启用触控功能。使用布尔值来打开/关闭触控代码 if (touchEnabled) { // do touch

我想禁用Cocos2d屏幕中的触摸功能。我要触摸禁用4-5秒,有人帮我吗。
谢谢

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

if (touchEnabled)
{
  // do touch code
}
else
{
  // not …
}
在其他地方,暂时禁用触摸:

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

我让您重新启用触控功能。

使用布尔值来打开/关闭触控代码

if (touchEnabled)
{
  // do touch code
}
else
{
  // not …
}
在其他地方,暂时禁用触摸:

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

我让您重新启用润色功能。

您还可以设置自定义计时器:

static Integer time = 100;
需要时倒计时:

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

如果(时间也可以设置自定义计时器:

static Integer time = 100;
需要时倒计时:

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

如果(时间定义一个时间变量

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");
        }   
    }

定义一个时间变量

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");
        }   
    }

您可以禁用触摸并调用调度方法,时间为5秒

setIsTouchEnabled(false);
schedule("enableTouchAfter5sec",5f);//5f is the duration after that method calls
在enableTouchAfter5sec方法中启用触摸

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

    }

您可以禁用触摸并调用调度方法,时间为5秒

setIsTouchEnabled(false);
schedule("enableTouchAfter5sec",5f);//5f is the duration after that method calls
在enableTouchAfter5sec方法中启用触摸

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

    }