Tag Archives: Interval

Show Alert in cocos2D Android.

By | February 4, 2012

Here is a simple example showing alert in android cocos2D. For this I am using an example from my previous android cocos2D tutorial.. So please read that tutorial before reading this because the I am using the classes and files from it. I am only changing the Gamelayer.java file to show an Alert Dialog when the sprite move… Read More »

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 »