I am writing a game in box2d / cocos2d where things fall from the sky, when they touch the floor or the player they should be removed from the scene. I have implemented a ContactListener as per Ray Wenderlich’s tutorial but the issue with it is that anytime ANYTHING touches anything it gets removed.
What I need is for some way to know which are objects that can be removed. I see there is a SetUserData function in Box2d where I can set data but it will not accept ints and seems to accept a class only which seems to add unnecessary complications.
What is the simplest way to achieve what I want?
Try this out:
It is using the new Objective-C literal syntax for wrapping the primitive type
intin an object. The object is wrapped in aNSNumber.@(yourInt)is equivalent with saying[NSNumber numberWithInt:yourInt]