Skip to content
2 changes: 2 additions & 0 deletions cocos/physics/CCPhysicsWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ void PhysicsWorld::debugDraw()
{
_debugDraw = DrawNode::create();
_debugDraw->setIsolated(true);
_debugDraw->setGlobalZOrder(_debugDrawGlobalZOrder);
_debugDraw->retain();
Director::getInstance()->getRunningScene()->addChild(_debugDraw);
}
Expand Down Expand Up @@ -990,6 +991,7 @@ PhysicsWorld::PhysicsWorld()
, _debugDraw(nullptr)
, _debugDrawMask(DEBUGDRAW_NONE)
, _eventDispatcher(nullptr)
, _debugDrawGlobalZOrder(0.f)
{

}
Expand Down
10 changes: 8 additions & 2 deletions cocos/physics/CCPhysicsWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -396,7 +401,8 @@ class CC_DLL PhysicsWorld
bool _autoStep;
DrawNode* _debugDraw;
int _debugDrawMask;

float _debugDrawGlobalZOrder;

EventDispatcher* _eventDispatcher;

Vector<PhysicsBody*> _delayAddBodies;
Expand Down