How to enable Box2d debug draw with Coco2d-x 3.0 beta 2

后端 未结 4 1533
清酒与你
清酒与你 2021-01-27 05:07

How I should enable debug draw with Cocos2d-x 3.0? There are some codes that do that with cocos2d-x 2.0 but they don\'t even compile on Cocos2d-x. Unfortunately I am new to both

4条回答
  •  梦如初夏
    2021-01-27 06:10

    You CANNOT bring bodies to front. if you want to see your bodies behind your sprites you can set their opacity as sprite->setOpacity(100).

    i use the following code to draw

    void GameLayer:: setPhysics() {
    b2Vec2 gravity = b2Vec2(0.0f,0.0f);// Initializing World
    world = new b2World(gravity);
    
    m_debugDraw = new GLESDebugDraw( PTM_RATIO );
    world->SetDebugDraw(m_debugDraw);
    
    world->SetAllowSleeping(false);
    
    uint32 flags = 0;
    flags += b2Draw::e_shapeBit;
    //        flags += b2Draw::e_jointBit;
    //        flags += b2Draw::e_aabbBit;
    //        flags += b2Draw::e_pairBit;
    //        flags += b2Draw::e_centerOfMassBit;
    m_debugDraw->SetFlags(flags);
    
    contactListener = new MyContactListener(this);
    world->SetContactListener(contactListener);
    }
    

    which is same as yours.... can you please xplain your problem a bit more

提交回复
热议问题