Tag Archives: Userdata

Simulate a Balloon in Box2D, iPhone or ANDROID

By | April 12, 2012

Hello……… Sometimes you may want your body to act against the gravity of the world. One method to do this is described below. First what you have to do is to make a body in the shape of a circle and give it the image of a balloon as the userdata. Then in the tick function write this… Read More »

How to check whether you have touched a body in Box2D iPhone?

By | January 30, 2011

You can check it by using the TestPoint function available for the Fixtures. [xml] – (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *myTouch = [touches anyObject]; CGPoint location = [myTouch locationInView:[myTouch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO); for (b2Body *b = world->GetBodyList(); b; b = b->GetNext()) { b2Fixture *f = b->GetFixtureList(); CCSprite *sprite =(CCSprite… Read More »