我正在使用cocos2d 2.0 BETA 2.0创建一款游戏[最新版本]。我需要在其他课程中添加一个操纵杆。所以我在第二节课中称之为“CCTouchDispatcher”。但我不能这样打电话:
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
所以我做了这个:
_tocuhDispatcher = [[CCTouchDispatcher alloc] init];
[_tocuhDispatcher addTargetedDelegate:self priority:0 swallowsTouches:YES];
但仍然无法检测到触动。如果我启用HelloWorldLayer中的触摸,我可以移动我的对象,但没有操纵杆不起作用
我能做什么?
答案 0 :(得分:10)
CCDirector *director = [CCDirector sharedDirector];
[[director touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];