使用 CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC

Using CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC(使用 CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC)
本文介绍了使用 CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 cocos2d 2.0 BETA 2.0 [最新的] 创建一个游戏.我需要在其他班级添加一个操纵杆.所以我在第二堂课中称它为CCTouchDispatcher".但我不能这样打电话:

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];

所以我做了这个:

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

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

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

我能做什么?

推荐答案

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

这篇关于使用 CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How to stop UIBarButtonItem text from truncating?(如何阻止UIBarButtonItem文本被截断?)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)