Using CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC

只愿长相守 提交于 2019-12-21 05:41:06

问题


I am creating a game with cocos2d 2.0 BETA 2.0 [The newest one]. And i need to add a joystick in other class. so I call this "CCTouchDispatcher" in my second class. But I can't call like this:

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

So I made this one:

_tocuhDispatcher = [[CCTouchDispatcher alloc] init];
[_tocuhDispatcher addTargetedDelegate:self priority:0 swallowsTouches:YES];

But still can't detect the touches. If I enable the touches in my HelloWorldLayer I could move my object with the touches but no the joystick doesn't work

What could i do?


回答1:


CCDirector *director = [CCDirector sharedDirector];
[[director touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES]; 


来源:https://stackoverflow.com/questions/8965902/using-cctouchdispatcher-cocos2d-2-0-beta-2-arc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!