CCTouch on a Sprite?

CCTouch on a Sprite?
0.0 0


This is kind of a n00b question, but how to I detect if a CCTouch has touched a particular sprite? I have a vector of sprites and want to determine if a CCTouch event has landed on a particular sprite. One way would be to compute the geometry of the touch vs. the location and size of the sprite on the screen. Does another way exist? I tried the code below but that did not seem to work and CCTouch isn’t well documented in Doxygen.

void AvailibleUnits::ccTouchesBegan(cocos2d::CCSet* touches, cocos2d::CCEvent* event){
CCTouch* touch;
for(int i = 0; i < pUnitsCurrentlyDisplayed~~>size; i++){ //pUnitsCurrentlyDisplayed is of the type std::vector
touch = );
this~~>TouchBegin = touch->locationInView(touch->view());


I think you can refer the test case of TouchesTest.


Where is this TouchesTest located?






Thank you very much for the fast reply. :slight_smile: