We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.
Move _physicsWorld from Scene to Layer.
Move _physicsWorld from Scene to Layer.
Sweet! I'm glad this approach is being used.
Consider allowing the programmer to chose which layer will have the physics, instead of having the physics forced to the root layer of the scene.
If not, the programmer will be forced to counter-transform static layers like GUI layers because they will be part of the root layer. Unless they add multiple layers to the Scene which could have drawbacks for FX's and stuff.
@ricardo
Yes I'm working on this now.
I committed a PR at: https://github.com/cocos2d/cocos2d-x/pull/6288
Refactor is almost finished, Test case is uncompleted, I will add the test case recently.
@ricardo
I add a physics transform demo in PhysicsTest at my github repo use the newest develop codes:
https://github.com/boyu0/cocos2d-x/tree/physical_wrong_transform_demo
The position of sprites which have physics body are transformed incorrect, ignore this bug, just see the physics body part.
As you can see, if we want transform physics world, we need to transform the scene, but all the ui components are also the children of the scene, so we can't keep ui components at screen and only transform the physics world.
If we move physics world to layer, we can create two layers, one for physics and one for ui, and now we can transform the physics layer seperately. so we can have more control with it.
Bind physics world to Scene has lots of problems, It makes game created with physics hard to simulate the camera, and it breaks the code style of our engine usage (use layer to keep the local coordinate system, use layer for camera simulate, etc.), So move physics to Layer is more appropriate and sensible.