Search code examples
luabox2dgame-physicsgideros

Lua Box2d Gideros: Hide bodies


In Gideros studio box2d, bodies(which are basicly the physical object, not the picture that goes with it) always show up as a translucent shape. In my game, i don't want players to be able to see these bodies. I've seen that you can do this in corona, but I haven't seen anything about Gideros. Is there anyone who knows lua and box2d well enough to tell me how to do this? Thanks!


Solution

  • If it is really debug drawing, then click on top menu Edit, choose Find in files and search for DebugDraw

    You should find something like:

    local world = b2.World.new(0, 10, true)
    local debugDraw = b2.DebugDraw.new()
    world:setDebugDraw(debugDraw)
    stage:addChild(debugDraw)
    

    Just comment out the line --stage:addChild(debugDraw) and you are good to go. Remove setting debug draw completely for production for better performance

    You can setup some global variable debug and toggle it to enable/disable debug drawing:

    DEBUG = false
    

    and then later in your code

    if DEBUG then
        local world = b2.World.new(0, 10, true)
        local debugDraw = b2.DebugDraw.new()
        world:setDebugDraw(debugDraw)
        stage:addChild(debugDraw)
    end