Clicker.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include <Urho3D/Math/BigInt.h>
  5. #include "Sample.h"
  6. class Clicker : public Sample
  7. {
  8. URHO3D_OBJECT(Clicker, Sample);
  9. public:
  10. /// Construct.
  11. explicit Clicker(Context* context);
  12. /// Setup after engine initialization and before running the main loop.
  13. void Start() override;
  14. protected:
  15. /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
  16. String GetScreenJoystickPatchString() const override {
  17. return
  18. "<patch>"
  19. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
  20. " <attribute name=\"Is Visible\" value=\"false\" />"
  21. " </add>"
  22. "</patch>";
  23. }
  24. private:
  25. /// Current score.
  26. BigInt score_;
  27. /// Number of points received per click.
  28. BigInt power_{1};
  29. /// Delay after click.
  30. float clickDelay_ = 0.f;
  31. /// Construct UI elements.
  32. void CreateUI();
  33. /// Subscribe to application-wide logic update events.
  34. void SubscribeToEvents();
  35. /// Handle the logic update event.
  36. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  37. /// Handle the mouse click event.
  38. void HandleMouseButtonDown(StringHash eventType, VariantMap& eventData);
  39. };