Cocos2d-x v3.8.1 Physics Problem

Hello. I have a problem in my game and I think it’s from the physics engine. So, basically I have some sprites on the screen and after I add physics bodies to them they disappear sometimes from the screen when I run the project. Can anyone help me please?

Thank you!

That’s a bug, right now it’s not fixed. So basically the problem is about teleport with the node physics they not appear always at the same place.

You can fix this issue using this two options (If someone else know another fix please tell):

  • Override “onEnterTransitionDidFinish”
  • Use an old version of cocos 2d-x, version 3.6 down don’t have this problem.
  • Maybe not using transitions scenes.

Bug report here: https://github.com/cocos2d/cocos2d-x/issues/12567#issuecomment-122970403

Thank you very much! I am wondering whether this problem appears if I use the box2d physics engine.

When you use the built in physics wrapper in Cocos2d-x, such as using the cocos2d::PhysicsBody, cocos2d::PhysicsWorld, etc., then you are using code that provides a wrapper only around Chipmunk.

The bug is in the Cocos2d-x code that wraps the Chipmunk physics engine, not with Chipmunk.

So if you use Chipmunk or Box2D directly, then you will not experience the “teleport” issue.

Now I understand. Thank you very much!