Cocos2d-x 3.0 beta2 PhysicsWorld not moving with layer

Cocos2d-x 3.0 beta2 PhysicsWorld not moving with layer
0.0 0


Hi everyone, I’ve been playing with the new integrated physics implementation in the 3.0 beta 2 release, and can’t see a way to get the PhysicsWorld to move and scale with a layer (so that I can achieve camera panning effects). I create the scene and child layer in the same way as shown in the documentation:

auto scene = Scene::createWithPhysics();

auto layer = HelloWorld::create();

Adding sprites and setting their body with sprite->setPhysicsBody works as expected, but as soon as I start to move the layer for camera panning etc, the shapes and bodies move out of sync with the sprite. I assume this is because the PhysicsWorld is bound to the parent scene, and not the child layer. Does anyone know how to bind the PhysicsWorld to the child layer, so that it moves and scales with it?



Cocos2d-x 3.0 not moving with layer PhysicsSprite

It’s a bug.
It was a PR for this bug:

It changes body position to relative parent.
I will continue this PR to fix it.
But I don’t have any solution for scales a body, The only way I know is destroy the body and create it with new size.
I will do some research for it.


Thank you bo, I guess what I’m looking for is the physics shapes and bodies to be moved and scaled with the layer, as they are when using chipmunk without the integrated physics components.


Is there a way to get this fix? I just figured out that the physics isn’t panning with the game play layer. This makes debugging physics almost impossible.


@Marquisd, it fixed and merged at this PR: