This project has moved and is read-only. For the latest updates, please go here.

How can I resize a Body?

Topics: User Forum
Dec 30, 2013 at 10:35 PM
I want that a ball gets bigger until it reached a fixed limit. For example, the limit of the ball's radius should be 250 pixel. But at the beginning(when the game starts), the ball's radius is only 25 pixel.
How can I resize the body so that the body is getting bigger every second?
My code:
Ball = BodyFactory.CreateCircle(world, 0.25f, 1.0f);
Ball.BodyType = BodyType.Dynamic;
Ball.Position = new Vector2(0.5f, 2f);
Ball.IsSensor = false;
Ball.LinearVelocity = new Vector2(2f, 0f);
Ball.CollisionCategories = Category.Cat20;

protected override void Update(GameTime gameTime)
            elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
            world.Step(Math.Min(elapsed, (1f / 60f)));


 spriteBatch.Draw(BallSprite, ConvertUnits.ToDisplayUnits(Ball.Position),
                                     Color.White, Ball.Rotation, new Vector2(BallSprite.Width / 2.0f, BallSprite.Height / 2.0f), 1f,
                                     SpriteEffects.None, 0f);
Dec 31, 2013 at 1:17 AM
Edited Dec 31, 2013 at 1:36 AM
Just remove the old body from the world and re-create it using the bigger radius. Don't forget to note the stats for the body like its position and velocity before you remove it.
Marked as answer by Wizard999 on 1/2/2014 at 11:28 AM
Dec 31, 2013 at 9:53 AM
Is that the only way to do it or is it possible to use only one body?
Dec 31, 2013 at 7:38 PM
Edited Dec 31, 2013 at 7:39 PM
From what I've read on here, resizing fixtures after creation isn't recommended as it can lead to weird results.

Check out the link below for weigh-ins from the big dogs
Jan 2, 2014 at 7:28 PM
It works when I remove the old body from the world and recreate the body using a bigger radius.