I am a beginner in cocos2dx ios game development.I have 12 sprites in a CCArray and they are falling from top to bottom of the screen randomly. Any sprite can appear any time. I have done layering that the sprite at array index 0 will come at layer 12 and at index 1 will come at layer 11 and so on.So that the sprite coming first appear ahead of the sprite coming second. But the point is this situation is not always true.The sprites can come like index 5 first and then index 4 and so on. So how to detect collision of the sprites present in the same array such that if they touch each others bounding box then I can make them slow for a second or something else so that they don't overlap with each other.I am not using Box2d and don't want to use it. I just want answer without using box2d and only in cocos2dx using c++.Anyone who can help me Thanks
CCArray mbox;
Write this code in update
for(int i = 0; i<mbox_count();i++)
for(int j = i+1; j<mbox_count();j++)
{
CCSprite* sp = static_cast<CCSprite*>mbox->objectatindex(j);
CCSprite* sp1 = static_cast<CCSprite*>mbox->objectatindex(i);
if(sp1->boundingBox().intersectsRect(sp->boundingBox()))
{
//whatever you want to do;
}
}