pygamechipmunkpymunk

Changing constraint colors in pymunk/pygame


I am working on a project using pymunk and pygame. I am using PivotJoint constraints to attach my bodies together. I would like to make the joints invisible if possible - is there any way to do this? Right now the joints appear purple in pygame and I don't seem to be able to change their color.

Thanks!


Solution

  • Yes, you can disable drawing of constraints by setting the flags property on the SpaceDebugDrawOptions object to only include shapes, or if you prefer include both shapes and collisions: http://www.pymunk.org/en/latest/pymunk.html#pymunk.SpaceDebugDrawOptions.flags

    in this way to draw only shapes

    options = pymunk.pygame_util.DrawOptions(screen)
    options.flags = pymunk.SpaceDebugDrawOptions.DRAW_SHAPES
    

    or like this to draw both shapes and collisions

    options = pymunk.pygame_util.DrawOptions(screen)
    options.flags = pymunk.SpaceDebugDrawOptions.DRAW_SHAPES | pymunk.SpaceDebugDrawOptions.DRAW_COLLISION_POINTS