4

cocos2d 2.0 BETA 2.0【最新のもの】でゲームを作っています。そして、他のクラスにジョイスティックを追加する必要があります。そのため、2 番目のクラスではこれを「CCTouchDispatcher」と呼んでいます。しかし、私はこのように呼び出すことはできません:

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

だから私はこれを作った:

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

しかし、まだタッチを検出できません。HelloWorldLayer でタッチを有効にすると、タッチでオブジェクトを移動できますが、ジョイスティックは機能しません

どうすればいいですか?

4

1 に答える 1

10
CCDirector *director = [CCDirector sharedDirector];
[[director touchDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES]; 
于 2012-01-30T05:37:30.873 に答える