This question is slightly XNA based but also applies to general use so I decided to ask here..
When creating objects while using box2D do I need to make a new FixtureDef / BodyDef etc. for each seperate physics body or can I re-use the Definitions without oddness occuring?
Any other best practice tips are appreciated too,
Thank you!
When creating objects while using box2D do I need to make a new FixtureDef / BodyDef etc. for each seperate physics body or can I re-use the Definitions without oddness occuring?
Any other best practice tips are appreciated too,
Thank you!
Code:
public EntityType SpawnStaticBox()
{
Ent = new EntityType();
BD = new BodyDef(); // New garbage, Can I do this once?
poly = new PolygonShape(); // .. Or must each final body have unique parts?
BD.position = new Vector2(0f, 7f);
BD.type = BodyType.Static;
poly.SetAsBox(1f, 1f);
B = world2D.CreateBody(BD);
B.CreateFixture(poly, 0f);
B.SetUserData(Ent);
Ent.myBody = B;
Ent.Live = true;
return Ent;
}
{
Ent = new EntityType();
BD = new BodyDef(); // New garbage, Can I do this once?
poly = new PolygonShape(); // .. Or must each final body have unique parts?
BD.position = new Vector2(0f, 7f);
BD.type = BodyType.Static;
poly.SetAsBox(1f, 1f);
B = world2D.CreateBody(BD);
B.CreateFixture(poly, 0f);
B.SetUserData(Ent);
Ent.myBody = B;
Ent.Live = true;
return Ent;
}