Using CCTouchDispatcher Cocos2d 2.0 Beta-2 ARC
Asked Answered
H

1

4

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?

Hirudin answered 23/1, 2012 at 0:3 Comment(0)
S
10
CCDirector *director = [CCDirector sharedDirector];
[[director touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES]; 
Subtend answered 30/1, 2012 at 5:37 Comment(1)
I will try it, but I already solve it, I take the touch events in my main game and transfer them to my nsobjectHirudin

© 2022 - 2024 — McMap. All rights reserved.