Tag Archives: groupIndex

How to rotate a body manually in Box2D?

By | January 24, 2011

The below code helps you to rotate a body in Box2D manually. [java] -(void) start { rot_sprite = [CCSprite spriteWithFile:[NSString stringWithFormat:@"rot_sprite.png" ]]; [self addChild: rot_sprite]; b2BodyDef bodyDef; b2Vec2 initVel; b2PolygonShape shape; b2CircleShape circleShape; b2FixtureDef fd; b2Body * rotating_body; b2RevoluteJointDef revJointDef; b2DistanceJointDef jointDef; b2Vec2 pos; bodyDef.position.Set(11.043825f, 4.984064f); bodyDef.angle = 0.000000f; bodyDef.userData = rot_sprite; rotating_body = world->CreateBody(&bodyDef;); initVel.Set(0.000000f, 0.000000f); rotating_body->SetLinearVelocity(initVel);… Read More »