Which physics engine am I using in Cocos2dx Chipmunk or Box2d

Hello I am a new comer to game programming and wanted to know a little bit about the physics engine I am currently using. I have read that cocos2dx has 2 engines integrated init Box2d and chipmunk. I am currently creating ohysics bodies as such

auto physicsBody = PhysicsBody::createBox(Size(65.0f, 81.0f), PhysicsMaterial(0.1f, 1.0f, 0.0f));
physicsBody->setDynamic(false);

//create a sprite
auto sprite = Sprite::create("whiteSprite.png");
sprite->setPosition(s_centre);
addChild(sprite);

//apply physicsBody to the sprite
sprite->setPhysicsBody(physicsBody);

//add five dynamic body
for (int i = 0; i < 5; ++i)
{
    physicsBody = PhysicsBody::createBox(Size(65.0f, 81.0f),
                    PhysicsMaterial(0.1f, 1.0f, 0.0f));

    //set the body isn't affected by the physics world's gravitational force
    physicsBody->setGravityEnable(false);

    //set initial velocity of physicsBody
    physicsBody->setVelocity(Vec2(cocos2d::random(-500,500),
                cocos2d::random(-500,500)));
    physicsBody->setTag(DRAG_BODYS_TAG);

    sprite = Sprite::create("blueSprite.png");
    sprite->setPosition(Vec2(s_centre.x + cocos2d::random(-300,300),
                s_centre.y + cocos2d::random(-300,300)));
    sprite->setPhysicsBody(physicsBody);

    addChild(sprite);
}

My question is i am not sure what physics engine I am using here. Is it box2d or chipmunk. ?

You are using Chipmunk.

1 Like

By default you are using chipmunk

But , you can use box2d as well … It’s depends on what you are familiar with

For now chipmunk doing very well… Also the version 7 now become open source and free

Hope see it , with cocos2dx next version

Btw, if you are new , keep using chipmunk with cocos2dx helpers for manage the physics

Will be easy for you…

Good luck

1 Like

Thanks for clearing that up

btw, you will get better results using Box2D and you can then use this… http://google.github.io/liquidfun/

2 Likes

Thanks for the reply. I am currently having issues with Continuous collision detection. I have read that chipmunk does not support that due to which my character passes through static bodies. I have my issue mentioned here in detail
to which you have already replied and I would be testing that out later today. Are you suggesting that I use Box2d instead ? Are there any cocos2dx box2d tutorials that you would suggest ?

Using Box2D with cocos is a little more difficult than the built in Chipmunk.
However you will soon come against problems using the in-built physics.
Google is your friend. For what its worth 99% of physics games use Box2D

Thanks for the suggestion. Ill look into this.

Remember also, no matter what physics engine you use.
You cannot go around using setPosition in general.
You have to move objects using setVelocity or applyForce etc
Otherwise things will just not work well…

1 Like

I did not know liquidfun! it seems pretty impressive. Have you tested its performance (box2d + liquidfun) in low-end mobile devices?

Yes. The slowest device I tested it on was a 4th gen iPod. You can simulate many 100s of LiquidFun particles at 60Hz.
Enough to be useful in a proper game.

Anyone know where I can get help getting any kind on win32 box2d example working. I just cant get anything working, Noop, its painful