Вопрос

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?

Это было полезно?

Решение

Try this

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

and call

- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
    return YES;
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top