Urho2DPhysicsRope.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "Sample.h"
  5. namespace Urho3D
  6. {
  7. class Node;
  8. class Scene;
  9. class ConstraintRope2D;
  10. }
  11. /// Physics2D rope sample.
  12. /// This sample demonstrates:
  13. /// - Create revolute constraint
  14. /// - Create roop constraint
  15. /// - Displaying physics debug geometry
  16. class Urho2DPhysicsRope : public Sample
  17. {
  18. URHO3D_OBJECT(Urho2DPhysicsRope, Sample);
  19. public:
  20. /// Construct.
  21. explicit Urho2DPhysicsRope(Context* context);
  22. /// Setup after engine initialization and before running the main loop.
  23. void Start() override;
  24. protected:
  25. /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
  26. String GetScreenJoystickPatchString() const override { return
  27. "<patch>"
  28. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/attribute[@name='Is Visible']\" />"
  29. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Zoom In</replace>"
  30. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button0']]\">"
  31. " <element type=\"Text\">"
  32. " <attribute name=\"Name\" value=\"KeyBinding\" />"
  33. " <attribute name=\"Text\" value=\"PAGEUP\" />"
  34. " </element>"
  35. " </add>"
  36. " <remove sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/attribute[@name='Is Visible']\" />"
  37. " <replace sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]/element[./attribute[@name='Name' and @value='Label']]/attribute[@name='Text']/@value\">Zoom Out</replace>"
  38. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Button1']]\">"
  39. " <element type=\"Text\">"
  40. " <attribute name=\"Name\" value=\"KeyBinding\" />"
  41. " <attribute name=\"Text\" value=\"PAGEDOWN\" />"
  42. " </element>"
  43. " </add>"
  44. "</patch>";
  45. }
  46. private:
  47. /// Construct the scene content.
  48. void CreateScene();
  49. /// Construct an instruction text to the UI.
  50. void CreateInstructions();
  51. /// Set up a viewport for displaying the scene.
  52. void SetupViewport();
  53. /// Read input and moves the camera.
  54. void MoveCamera(float timeStep);
  55. /// Subscribe to application-wide logic update events.
  56. void SubscribeToEvents();
  57. /// Handle the logic update event.
  58. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  59. };