Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Updating sprites from box2d body with multiple fixtures - Gideros Forum

Updating sprites from box2d body with multiple fixtures

pkfryerpkfryer Member
edited June 2012 in General questions
Just wondered if there was an easy way of taking a body with multiple fixtures and translating this during rendering into multiple sprites. For instead I had two rectangles added as separate fixtures and I wanted to render them with two separate shapes. How do i retrieve the individual fixture locations in order to render them correctly for a frame.

Dislikes: r033rt, gokhasahin477, Yan

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


  • ar2rsawseenar2rsawseen Maintainer
    Well, it depends on the purpose, why you don't want to use one image to represent whole body.

    If for example at some point you want to break body into pieces, where each fixture is a new piece, then you could use a sprite to group multiple images as one, and attach it to the body, like you'd do with normal image.
  • Thanks for the suggestion. There were a couple of reasons I wanted to use multiple fixtures. First one, is because its there and I was curious how to do it :) Second one was, because I've heard lots of discussions about using fixtures instead of welds was preferred but I could never find any examples of how to render the multiple fixtures when you only have the body position and rotation available.

    I want to be able to control of the fixtures so that i could add,remove and update them when needed. I also wanted the body to follow the exact shapes of the children.

    The specific problem that prompted me down this root is: i wanted to have a group of sprites, that I had anchored using a weld joint with fixed rotation. This seemed to be impossible to configure in box2d. Fixed rotation on the sprites put strain on the joints and pulled them a part. with the sprites welded together it was impossible to prevent them from rotating. I tried overriding the rotation value during 'enter frame' but this produced an interesting but undesired effect. So I came to the conclusion that the only correct way would be through fixtures, this way i should be able to fix the rotation of the body as a whole.
  • A related question to the above: does the b2.Shape have any getters? I've been playing with the idea of getting the attributes from a stored b2.Shape but I can't see any documented getters? Are there any or would I have to store the details myself in the table to access them?
  • ar2rsawseenar2rsawseen Maintainer
    I guess yes, you'll need to save the reference to shape or save all details about shape yourself.

    Don't know if you've seen this example:
  • bysregbysreg Member
    sorry for bumping old thread,

    i was searching for way to get all fixtures that attached to body. in box2d, it's GetFixturesList. But it seems it is currently not implemented yet
  • ar2rsawseenar2rsawseen Maintainer
    @bysreg yes not all box2d features are implemented, only the requested ones :)

    But for now I've always saved fixtures as properties of box2d body and then get them whenever I need to :)
  • DungDajHjepDungDajHjep Member
    edited August 2014
    resloved problem, just need set name for fixtures after creat fixtures

    body.fixtureFootSensor = body:createFixture{
    shape = poly,
    density = 0.000001,
    friction = 0,
    restitution = 0,
    isSensor = true
    body.fixtureFootSensor.Name = "FootSensor"

    so how i know a fixtures is in colission ?
    example: footSensor is colission with ground, foot sensor is multi fixtures with my body, i saw in box2d forums them used set user data and get user data
    but what i can do in gideros ?

    p/s: sorry im bad english :D

Sign In or Register to comment.