gpt4 book ai didi

iphone - 使用 CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC

转载 作者:太空狗 更新时间:2023-10-30 03:59:02 26 4
gpt4 key购买 nike

我正在使用 cocos2d 2.0 BETA 2.0 [最新的] 创建游戏。我需要在其他类(class)中添加一个操纵杆。所以我在第二节课上称这个为“CCTouchDispatcher”。但是我不能这样调用:

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

所以我做了这个:

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

但仍然无法检测到触摸。如果我在我的 HelloWorldLayer 中启用触摸,我可以通过触摸移动我的对象,但操纵杆不工作

我能做什么?

最佳答案

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

关于iphone - 使用 CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8965902/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com