onTouchesBegan etc on cc.Sprite?

onTouchesBegan etc on cc.Sprite?
0.0 0


is onTouchesBegan etc ? supported on cc.Sprites ?

I’m writing a class that extends cc.Sprite and wanted to receive touches to my class, however by default my class doesn’t seem to receive these events.

I’m not sure if this information is out of date, but on StackOverflow this posting http://stackoverflow.com/questions/2900691/best-practices-for-handling-touches-to-a-ccsprite-with-cocos2d seemed to indicate that the best practice was to receive onTouch events into a class that extends Sprite, but in the iOS code there was a declaration to indicate that the class implements CCTargetedTouchDelegate and also the class called [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];

But I’m not sure if there is an equivalent in HTML 5 ??

Or do I need to handle touches at the “layer” level in my code ??



cc.Sprite can’t receive and process touch events.

You need to process it in “Layer” at the moment.



I’ll do it in the game layer.