AdvancedDemo4.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Text;
  2. using Microsoft.Xna.Framework;
  3. namespace FarseerPhysics.SamplesFramework
  4. {
  5. internal class AdvancedDemo4 : PhysicsGameScreen, IDemoScreen
  6. {
  7. private Border _border;
  8. private Spiderweb _spiderweb;
  9. #region IDemoScreen Members
  10. public string GetTitle()
  11. {
  12. return "Advanced dynamics";
  13. }
  14. public string GetDetails()
  15. {
  16. StringBuilder sb = new StringBuilder();
  17. sb.AppendLine("TODO: Add sample description!");
  18. sb.AppendLine(string.Empty);
  19. sb.AppendLine("GamePad:");
  20. sb.AppendLine(" - Move cursor: left thumbstick");
  21. sb.AppendLine(" - Grab object (beneath cursor): A button");
  22. sb.AppendLine(" - Drag grabbed object: left thumbstick");
  23. sb.AppendLine(" - Exit to menu: Back button");
  24. sb.AppendLine(string.Empty);
  25. sb.AppendLine("Keyboard:");
  26. sb.AppendLine(" - Exit to menu: Escape");
  27. sb.AppendLine(string.Empty);
  28. sb.AppendLine("Mouse / Touchscreen");
  29. sb.AppendLine(" - Grab object (beneath cursor): Left click");
  30. sb.AppendLine(" - Drag grabbed object: move mouse / finger");
  31. return sb.ToString();
  32. }
  33. #endregion
  34. public override void LoadContent()
  35. {
  36. base.LoadContent();
  37. World.Gravity = new Vector2(0, 9.82f);
  38. _border = new Border(World, this, ScreenManager.GraphicsDevice.Viewport);
  39. #if DESKTOP || XBOX
  40. _spiderweb = new Spiderweb(World, Vector2.Zero, ConvertUnits.ToSimUnits(12), 5, 12);
  41. #elif WINDOWS_PHONE
  42. _spiderweb = new Spiderweb(World, Vector2.Zero, ConvertUnits.ToSimUnits(8), 5, 12);
  43. #endif
  44. _spiderweb.LoadContent(ScreenManager.Content);
  45. }
  46. public override void Draw(GameTime gameTime)
  47. {
  48. ScreenManager.SpriteBatch.Begin(0, null, null, null, null, null, Camera.View);
  49. _spiderweb.Draw(ScreenManager.SpriteBatch);
  50. ScreenManager.SpriteBatch.End();
  51. _border.Draw();
  52. base.Draw(gameTime);
  53. }
  54. }
  55. }