i want to disable touch in Cocos2d screen. i want touch disable for 4-5 second.any one help me. thanks
Cocos2d android Disable touch
558 Views Asked by Mitesh Jain At
4
There are 4 best solutions below
0

Define one time variable
static float time;
Write below code when you want to disable touch screen
this.schedule("touchdiablefor5sec",1f);
Now write below method
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

You can disable touch and call a schedule method with time 5 sec as
setIsTouchEnabled(false);
schedule("enableTouchAfter5sec",5f);//5f is the duration after that method calls
and in enableTouchAfter5sec method enable the touch
public void enableTouchAfter5sec(float dt) {
setIsTouchEnabled(true);
unschedule("enableTouchAfter5sec");
}
Use a bool value to toggle your touch code on/off.
Somewhere else, disable touch temporarily:
I leave re-enabling the touches up to you.