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];
}