Search code examples
c++cocos2d-xbox2d

Can i use Box2D-objects side by side with Cocos2d-X objects?


Cocos2d-x supports the physics engines Box2D and Chipmunk and i used it until now via Cocos2d-x objects like cocos2d::PhysicsWorld or cocos2d::PhysicsJoint (we're talking C++ here). Now i want to integrate some custom Joint that is available for Box2D. Also, i experience problems with tunneling at high speed that i hope to get rid of by implementing some objects directly with Box2D (b2World etc.).

Is it possible to define some Box2D objects and just add them to the Cocos2d-X physics? And if it's not, do i have to reimplement the whole physics stuff from world-start to fixture-end? The official Box2D tutorial doesn't mention the native objects at all and seems be a little outdated.


Solution

  • It seems no one is willing to answer this. As i progressed i can give others looking for an answer the hint, that i think you have to adapt completely to Box2D, create a b2world, add b2bodies etc. For me it wasn't complicated and the simulation is much more accurate. It solved the problems i was facing with the cocos2dx-objects, so if you run into problems like tunneling or want to use more sophisticated features of Box2D, i'd suggest switching.