Frage

Hello I am making a side scrolling cocos2d game. I have one class subclassed from CCLayer and other classes subclassed from CCSprite and CCNode. Can I use the ccTouch methods in the classes subclassed from CCSprite and CCNode, or can they only be in the class subclassed from CCLayer?

War es hilfreich?

Lösung

Try this

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

and call

- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
    return YES;
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top