Urho2DParticle.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. }
  10. // Urho2D particle example.
  11. // This sample demonstrates:
  12. // - Creating a 2D scene with particle
  13. // - Displaying the scene using the Renderer subsystem
  14. // - Handling mouse move to move particle
  15. class Urho2DParticle : public Sample
  16. {
  17. URHO3D_OBJECT(Urho2DParticle, Sample);
  18. public:
  19. /// Construct.
  20. explicit Urho2DParticle(Context* context);
  21. /// Setup after engine initialization and before running the main loop.
  22. void Start() override;
  23. protected:
  24. /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
  25. String GetScreenJoystickPatchString() const override { return
  26. "<patch>"
  27. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
  28. " <attribute name=\"Is Visible\" value=\"false\" />"
  29. " </add>"
  30. "</patch>";
  31. }
  32. private:
  33. /// Construct the scene content.
  34. void CreateScene();
  35. /// Construct an instruction text to the UI.
  36. void CreateInstructions();
  37. /// Set up a viewport for displaying the scene.
  38. void SetupViewport();
  39. /// Subscribe to application-wide logic update events.
  40. void SubscribeToEvents();
  41. /// Handle mouse move event.
  42. void HandleMouseMove(StringHash eventType, VariantMap& eventData);
  43. /// Particle scene node.
  44. SharedPtr<Node> particleNode_;
  45. };