I just tried Farseer and everything is working great. My problem is, that on touch the player should get an force up. Although the touch event works well, the player did not get an force!
Here my code:
public void Update()
{
if (acceleration.Y < 0)
{
body.Rotation += ConvertUnits.ToSimUnits(0.05f);
}
if (acceleration.Y > 0)
{
body.Rotation -= ConvertUnits.ToSimUnits(0.05f);
}
while (TouchPanel.IsGestureAvailable)
{
var gesture = TouchPanel.ReadGesture();
if (gesture.GestureType == GestureType.Tap || gesture.GestureType == GestureType.Flick)
{
Debug.WriteLine("Okey");
body.ApplyForce(new Vector2(0, -20));
}
}
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(playertexture, ConvertUnits.ToDisplayUnits(body.Position),null,Color.White, ConvertUnits.ToDisplayUnits(body.Rotation), new Vector2(playertexture.Width / 2, playertexture.Height / 2), 1f,SpriteEffects.None, 0f);
}
(new Vector2(0, 20)? Also is that your entire update loop? I don't know Farseer but, you seem to be missing the physics update. Usually you call update on the physics engine so it can apply the forces to the bodies, detect collisions and so on. – Byte56 May 17 '12 at 16:11