I have a hierarchy like this:
Scene
– gameWorld (CCLayer Z:0)
– player (CCSprite Z:1)
– spriteWorld (CCNode Z:0)
– bgSprite (CCSprite Z:0)
– enemy (CCSprite Z:0)
The spriteWorld gets rotated and the bgSprite gets moved around so any CCSprites placed on bgSprite has a rotated and moved coordinate system compared to the gameWorld coordinate system.
I need to detected collisions between CCSprites placed both on the gameWorld and bgSprite. Now I have seen this post here:
Cocos2D CCNode position in absolute screen coordinates
which can give me each sprites position relative to the screen, but how do I then calculate or get the bounding box for these sprites? Those bounding boxes are rotate both via the spriteWorld rotation but each sprite also rotates on the bgSprite.
Sounds like a lot of crazy math to me and I am a fool at math, so I really really need help here.
Thank you
Særen
Indeed, cocos2D has no direct support for collision detection, so you would need to do all your calculations on your own.
Anyway, you can use a framework like chipmunk-physics or Box2D to do that for you. The basic idea is that you associate a body/shape to your sprite and then setup a collision callback that will be fired when the collision is detected, without worrying about the math…
Have a look at this article about using Box2D just for collision detection.