Reputation: 71
I'm using pymunk and I want to call the coordinates of a circle but it seems to be impossible for me.
For poly objects it's ps = logo_shape.get_vertices()
but when the logo_shape
refers to a circle object, I get this error from python :
File "D:/package/essai_optimisé(test).py", line 233, in main
ps = logo_shape.get_vertices()
AttributeError: 'Circle' object has no attribute 'get_vertices'
I just want to add an image at a dynamic ball and make the image rotate like the ball itself.
Thanks by advance :)
Upvotes: 2
Views: 311
Reputation: 4603
Circles work a little different from polygons, what you can get it is the center of the circle, its radius and its angle. But that should be enough if you just want to display an image where the circle is.
Basically
center = circle.body.position + circle.offset.rotated(circle.body.angle)
radius = circle.radius # scale image to match this
Take a look at draw_circle in pygame_util.py that is included with pymunk: https://github.com/viblo/pymunk/blob/master/pymunk/pygame_util.py
Upvotes: 2