【问题标题】:Using CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC使用 CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC
【发布时间】:2012-01-23 00:03:01
【问题描述】:

我正在用 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 中启用触摸,我可以通过触摸移动我的对象,但操纵杆不起作用

我能做什么?

【问题讨论】:

    标签: iphone objective-c cocos2d-iphone joystick


    【解决方案1】:
    CCDirector *director = [CCDirector sharedDirector];
    [[director touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES]; 
    

    【讨论】:

    • 我会尝试,但我已经解决了,我将主游戏中的触摸事件转移到我的 nsobject 中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    相关资源
    最近更新 更多