Page 1 of 1
Position of body when two shapes using it
Posted: Wed Feb 09, 2011 2:41 pm
by sumitkum
If two shapes are using a same body, then how will we set the position of the body
body->p = shape1.position;
or
body->p = shape2.position;
How should I handle it
Re: Position of body when two shapes using it
Posted: Wed Feb 09, 2011 2:57 pm
by slembcke
Shapes are always positioned relative to bodies. When the body moves, so will the shapes.
Re: Position of body when two shapes using it
Posted: Wed Feb 09, 2011 3:33 pm
by sumitkum
Yes, shapes will be updated according to the position of body. But, Don't we have to give initial position of body.
Re: Position of body when two shapes using it
Posted: Wed Feb 09, 2011 3:53 pm
by slembcke
The position of the body is the position of it's center of gravity. The shapes move and rotate around that.
So when you set the position of the body initially, you are setting it's center of gravity. The shapes attached are always relative to that.
Re: Position of body when two shapes using it
Posted: Wed Feb 09, 2011 4:17 pm
by sumitkum
I got it, Thanks for your help