private void CreateRectangle(TiledObject obj) { float rectWidth = ConvertUnits.ToSimUnits(obj.Width); float rectHeight = ConvertUnits.ToSimUnits(obj.Height); var body = BodyFactory.CreateRectangle( physicsWorld, rectWidth, rectHeight, obj.GetDensity()); body.Position = obj.GetObjectCenter(); body.FixedRotation = true; body.BodyType = BodyType.Static; }
public Entity(World world, TiledObject obj) { if (world == null) { throw new ArgumentNullException(nameof(world)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } Body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(obj.Width), ConvertUnits.ToSimUnits(obj.Height), obj.GetDensity(), this); Body.OnCollision += ContactListener.OnCollision; Body.OnSeparation += ContactListener.OnSeparation; Body.FixedRotation = true; }