Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How to remove a fixture from a body? — Gideros Forum

How to remove a fixture from a body?

RogerTRogerT Member
edited February 2013 in General questions
Hi guys,
If I make a fixture like this

local shape = b2.CircleShape.new(0, 0, 40)
body.fix = body:createFixture{shape = shape, density = 10, restitution = 0.2, friction = 0.1, filter = filter}

then I can remove it using

body:destroyFixture(body.fix)

but how do I destroy it, if I load it from a file as here?

body.physics = (loadfile "virusA/virusA_collide.lua")().physicsData(1)
body.physics:addFixture(body, "virA")

Thanks! )

Likes: RogerT

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • @RogerT do you use some physics editor that provides that file?
  • ar2rsawseenar2rsawseen Maintainer
    Accepted Answer
    amm, ok. which one? :)
    Basically I'm not using any so I still would not know, but what you can do, is to try to print all object/properties/methods underneath to find which object has the :destroyFixture(body.fix) method

    you can use this print_r function
    --recursive print of tables
    function print_r (t, indent, done)
      done = done or {}
      indent = indent or ''
      local nextIndent -- Storage for next indentation value
      for key, value in pairs (t) do
        if type (value) == "table" and not done [value] then
          nextIndent = nextIndent or
              (indent .. string.rep(' ',string.len(tostring (key))+2))
              -- Shortcut conditional allocation
          done [value] = true
          print (indent .. "[" .. tostring (key) .. "] => Table {");
          print  (nextIndent .. "{");
          print_r (value, nextIndent .. string.rep(' ',2), done)
          print  (nextIndent .. "}");
        else
          print  (indent .. "[" .. tostring (key) .. "] => " .. tostring (value).."")
        end
      end
    end
    And use it like:
    print_r(body)

    Likes: RogerT

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.