I created a sprite in cocos creator and added rigidbody(dynamic) to it . When i run the project, the the sprite was not affected by gravity( did not move down). Any idea? Thank you in advance.
I had the same issue.
create a javascript file in your asset folder and copy this code. You don’t need to attach it to any object, it just need to be in your assets folder.
let physicsManager = cc.director.getPhysicsManager();
physicsManager.enabled = true;
physicsManager.debugDrawFlags =
// 0;
// cc.PhysicsManager.DrawBits.e_aabbBit |
// cc.PhysicsManager.DrawBits.e_pairBit |
// cc.PhysicsManager.DrawBits.e_centerOfMassBit |
cc.PhysicsManager.DrawBits.e_jointBit |
cc.PhysicsManager.DrawBits.e_shapeBit
;
4 Likes
Thank you, it work perfectly fine now
Hi jejeman…
I did the same and it worked.
Can you explain how and why this works ?
Thanks for the fix btw !
let physicsManager = cc.director.getPhysicsManager(); // get the physics manager
physicsManager.enabled = true; // enables it
physicsManager.debugDrawFlags = 1; // turn on the physics debugger
more info:
http://cocos2d-x.org/docs/api-ref/creator/v1.5/classes/PhysicsManager.html
1 Like