I'm making an iOS game using cocos2d with Box2D and I'm wondering how to best handle collisions with collectable objects such as coins. The player is a dynamic body but coins and other collectables will (usually) be static bodies. Would it be better to create contact listeners between the player and these objects or just iterate over each coin in the game loop (ruling out any coins that are off screen, etc.) and perform circular collision detection on them?
The latter solution seems reasonable to me but I'm inexperienced with box2D and unsure what the advantages/disadvantages and performance costs are when using contact listeners, so I'm not sure if that may be better.
User data is a void pointer. This gives you a hook to link your application objects to bodies. You should be consistent to use the same object type for all body user data.
If you really don't like doing it, create a parent object with a CCSprite and b2body members and use the parent object to sync them. The userData would then point to the parent object. – Pat