2012-05-17 288 views
16

我已添加此功能。'sharedDispatcher'已弃用

- (void) registerWithTouchDispatcher { 
    [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES]; 
} 

错误:sharedDispatcher已被弃用

这是什么意思和我怎么办?

回答

42

看看ccDeprecated.h,上面写着使用方法:

[[CCDirector sharedDirector] touchDispatcher]

+1

不错!我不知道ccDeprecated.h甚至存在。感谢您指出了这一点。希望用户在那里会接受你的答案。 – CaldwellYSR

+1

哇。谢谢!我不知道这个文件是否存在,这有助于很多 –

16

变化: [CCTouchDispatcher sharedDispatcher] addTargetedDelegate:自我优先级:0 swallowsTouches:YES];

收件人: [[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];

3

通过按'Shift + Command'键并悬停在方法上,您可以检查任何Cocos(CC)方法背后的Cocos2D代码。对任何被弃用的方法这样做会带你到CCDeprecated.m,这也会给你新的方法。