diff --git a/cocos/physics/CCPhysicsWorld.cpp b/cocos/physics/CCPhysicsWorld.cpp index cd6effd739f2..dcf16ffbffef 100644 --- a/cocos/physics/CCPhysicsWorld.cpp +++ b/cocos/physics/CCPhysicsWorld.cpp @@ -271,6 +271,7 @@ void PhysicsWorld::debugDraw() { _debugDraw = DrawNode::create(); _debugDraw->setIsolated(true); + _debugDraw->setGlobalZOrder(_debugDrawGlobalZOrder); _debugDraw->retain(); Director::getInstance()->getRunningScene()->addChild(_debugDraw); } @@ -990,6 +991,7 @@ PhysicsWorld::PhysicsWorld() , _debugDraw(nullptr) , _debugDrawMask(DEBUGDRAW_NONE) , _eventDispatcher(nullptr) +, _debugDrawGlobalZOrder(0.f) { } diff --git a/cocos/physics/CCPhysicsWorld.h b/cocos/physics/CCPhysicsWorld.h index e6cb026327b5..65ce24981e9f 100644 --- a/cocos/physics/CCPhysicsWorld.h +++ b/cocos/physics/CCPhysicsWorld.h @@ -326,7 +326,12 @@ class CC_DLL PhysicsWorld * @return An integer number. */ int getDebugDrawMask() { return _debugDrawMask; } - + + /** + * Set the debug draw global Z order. + */ + void setDebugDrawGlobalZOrder(float globalZOrder) { _debugDrawGlobalZOrder = globalZOrder; } + /** * To control the step of physics. * @@ -396,7 +401,8 @@ class CC_DLL PhysicsWorld bool _autoStep; DrawNode* _debugDraw; int _debugDrawMask; - + float _debugDrawGlobalZOrder; + EventDispatcher* _eventDispatcher; Vector _delayAddBodies;