Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
how to change fixture - Gideros Forum

how to change fixture

alexzhengalexzheng Guru
edited November 2011 in Announcements
can I change the fixture definition of a fixture after attached to a body?
for example,making the player become smaller after colliding with some thing

Likes: JFonS

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

Comments

  • atilimatilim Maintainer
    edited November 2011
    Box2d API allows this. (you can get the shape from fixture and then modify it). But we haven't wrap this functionality yet. Optionally, you can destroy fixture and then create new fixture again. I'm adding this to the requests list. With the next version, we'll implement getting shapes from fixtures.


    Edit: I think, if you store your shape, you can modify it later. For example:
    local shape = b2.CircleShape.new(0, 0, 30)  -- it's radius is 30
    local fixture = body:createFixture({shape = shape, density = 1})
    fixture.shape = shape --> we store the shape here
     
    -- later.....
     
    fixture.shape:set(0, 0, 20) -- make radius 20

    Edit 2: Also, there is a warning at box2d's reference manual: You can modify the child shape, however you should not change the number of vertices because this will crash some collision caching mechanisms. Manipulating the shape may lead to non-physical behavior.
Sign In or Register to comment.