Projects > cpp > Issues > Bug #4771

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Move _physicsWorld from Scene to Layer.

Bug #4771 [Closed]
boyu0 2014-04-12 07:25 . Updated about 5 years ago

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.

Marquisd 2014-04-14 20:46

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 2014-04-15 02:32

Having the physics properties in Scene doesn't imply that all the objects on the Scene will be affected by physics.

I don't understand the issue with the camera and widgets.

Can you detail the Use Case, or create a test case and add it into the current cpp-test ?

Thanks.

boyu0 2014-04-15 06:15

@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.

boyu0 2014-04-16 03:07

@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.

boyu0 2014-05-03 14:55
  • Status changed from New to Closed
  • % Done changed from 0 to 100

Applied in changeset commit:33556c0b6047476ccd389a3354fe42671316da8b.

Atom PDF

Status:Closed
Start date:2014-04-12
Priority:High
Due date:
Assignee:boyu0
% Done:

100%

Category:all
Target version:v3.1