16

我已经添加了这个功能。

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

错误:sharedDispatcher已弃用

这是什么意思,我该怎么办?

4

3 回答 3

42

看一下ccDeprecated.h,它说要使用:

[[CCDirector sharedDirector] touchDispatcher]

于 2012-05-17T18:48:08.103 回答
16

更改:[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0swallowsTouches:YES];

To: [[[CCDirector sharedDirector] touchDispatcher] addTargetedDelegate:self priority:0swallowsTouches:YES];

于 2012-08-14T09:26:12.427 回答
3

您可以通过按“Shift+Command”键并将鼠标悬停在方法上来检查任何 Cocos (CC) 方法背后的 Cocos2D 代码。对任何不推荐使用的方法执行此操作会将您带到 CCDeprecated.m,这也将为您提供新方法。

于 2012-12-06T12:53:26.767 回答