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

if use farseer 3.2 then must use ConvertUnits ?

Topics: Developer Forum
Aug 1, 2011 at 10:15 AM

Currently I am using Farseer engine (version 3.3.1)


During development, i wonder one thing. so I try question

They've attached the relevant code, please note

when i make object

I use that

BodyFactory.CreateRectangle (world, width, height, mass, position); code

and Update (Gametime) at

 this.body.ApplyLinearImpulse (force, body.Position);

Draw (Gametime) at

  spriteBatch.Draw (texture, new Rectangle ((int) body.Position.X, (int) body.Position.Y, (int) width, (int) height), null, Color.White, body.Rotation, origin, SpriteEffects.None, 0f);

but they can't move

When the sample code distributed by a Farseer is ConvertUnits.cs 100f BodyFactory.Create share of attribute values ​​when the object is it (ConvertUnits.ToSimunit)

100.0f pictured again multiplied by the share neundeyo (ConvertUnits.ToDisplayUnits) this application to work when you need to do this is why I do not know, sir

if use farseer 3.2 then must use ConvertUnits ?

Attached to cut the relevant code. I wonder why that does not work ask for help

I wish you good day.



Aug 2, 2011 at 10:29 AM

Thats correct when setting any positions (when your thinking in pixels) you must convert it to world units (KMS) and back again to pixel units for drawing.

I would recommend using the ConvertUnits class that is available but remember to check the ratio, as different examples use different ratios which has caused me problems in the pass. 0.77 is a good starting point i.e. 77 pixels = 1 meter. But tune to your taste.

Hope that helps.