Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.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
Iphone 如何在cocos2d中禁用选择器的函数调用?_Iphone_Cocos2d Iphone_Selector - Fatal编程技术网

Iphone 如何在cocos2d中禁用选择器的函数调用?

Iphone 如何在cocos2d中禁用选择器的函数调用?,iphone,cocos2d-iphone,selector,Iphone,Cocos2d Iphone,Selector,我在选择器中设置了一个函数。函数调用后,我不想调用选择器。我编写了这行代码,但它引发了一个异常: self.touchselector = nil; 如何在cocos2d中重置选择器的功能?试试这个: [NSNotification cancelPreviousPerformRequestsWithTarget:self selector:@selector(powerHide) object:nil]; 假设您计划了与此类似的选择器: [self scheduleSelector:@sel

我在选择器中设置了一个函数。函数调用后,我不想调用选择器。我编写了这行代码,但它引发了一个异常:

self.touchselector = nil;
如何在cocos2d中重置选择器的功能?

试试这个:

[NSNotification cancelPreviousPerformRequestsWithTarget:self selector:@selector(powerHide) object:nil];

假设您计划了与此类似的选择器:

[self scheduleSelector:@selector(onTouch:) interval:1];
然后,您可以在该选择器通过_cmd调用的方法中取消该选择器的计划:

-(void) onTouch:(ccTime)delta
{
    // this will stop onTouch from being called every second
    [self unscheduleSelector:_cmd];
}