Hey, this is probably a simple question, but I couldn't find any properties that would help. I have a circle body and would like to give the illusion that it is coming 'out of the screen'. In order to do this, I simply want to uniformly scale the circle so that it gets bigger, in realtime. What's the best way to do this? Thanks
Scaling a circle body
General DiscussionIf it's just a circle it shouldn't be too dangerous to change it's radius directly.
Keep a pointer to the fixture, which you'll get when using b2Body::CreateFixture(*).
Access it's shape with b2Fixture::GetShape() and then alter it's m_radius property. The m_radius is part of b2Shape and not the derive b2CircleShape, so you shouldn't need an upcast.
Keep a pointer to the fixture, which you'll get when using b2Body::CreateFixture(*).
Access it's shape with b2Fixture::GetShape() and then alter it's m_radius property. The m_radius is part of b2Shape and not the derive b2CircleShape, so you shouldn't need an upcast.
Box2D API docs wrote:
b2Shape * b2Fixture::GetShape ( ) [inline]
Get the child shape. 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.
Get the child shape. 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.
Thanks Zoomulator! I wasn't sure if I should directly change the radius, but it's a circle that remains uniform throughout its life, and it seems to work just fine 🙂
Original thread: https://box2d.org/forum/viewtopic.php?t=6681