Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I test sprite collision in cocos2d?

How do I start to implement a class for sprite collision?

like image 430
user162304 Avatar asked Jan 23 '23 06:01

user162304


2 Answers

As Eric pointed out, CGRectIntersectsRect is the method to test two bounding rects for overlapping. Use the boundingBox method of the CCNode classes to get the correct bounding box for each sprite (or other node).

See my answer here: Collision Detection in Cocos2d game?

like image 87
LearnCocos2D Avatar answered Feb 15 '23 07:02

LearnCocos2D


I would look into b2ContactListener

You can do some searches on that, and you'll easily get some results

like image 32
yeahdixon Avatar answered Feb 15 '23 07:02

yeahdixon