The collision is not working correctly! The collision is in the "open-word" and not when it collides! Here my code:
Platform code(static):
body = BodyFactory.CreateRectangle(world, (float)ConvertUnits.ToSimUnits(textureplattform.Width), (float)ConvertUnits.ToSimUnits(textureplattform.Height),1f); body.BodyType = BodyType.Static; body.Position = new Vector2(ConvertUnits.ToSimUnits(Position.X) + textureplattform.Width/2,ConvertUnits.ToSimUnits(Position.Y) + textureplattform.Height/2); Player code(dynamic):
body = BodyFactory.CreateRectangle(world,(float)ConvertUnits.ToSimUnits(playertexture.Width), (float)ConvertUnits.ToSimUnits(playertexture.Height), 1f); body.BodyType = BodyType.Dynamic; body.Position = new Vector2(ConvertUnits.ToSimUnits(position.X), ConvertUnits.ToSimUnits(position.Y)); body.Mass = 1f; Player draw:
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); } Platform draw:
public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw(textureplattform, ConvertUnits.ToDisplayUnits(body.Position), colorplat); }