I am trying to create shapes using pymunk with pyglet. But I am facing a problem that I unable to change the color of a pymunk shape. They don't have any such attribute.
I have tried draw_polygon in pymunk.pyglet_utils.DrawOptions but there were no results. What are they for?
The color attribute does not exist from the start, but you can still set it.
This small snippet sets the color to red for example.
import pymunk
import pymunk.pygame_util
space = pymunk.Space()
options = pymunk.pyglet_util.DrawOptions()
body = pymunk.Body(1, 10)
shape = pymunk.Circle(body, 10)
shape.color = (255, 0, 0, 255) # will draw my_shape in red
space.add(body, shape)
space.debug_draw(options)
See http://www.pymunk.org/en/latest/pymunk.pyglet_util.html#pymunk.pyglet_util.DrawOptions.init
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With