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. ?
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
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…
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.