HelloWorld.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "Sample.h"
  5. /// This first example, maintaining tradition, prints a "Hello World" message.
  6. /// Furthermore it shows:
  7. /// - Using the Sample / Application classes, which initialize the Urho3D engine and run the main loop
  8. /// - Adding a Text element to the graphical user interface
  9. /// - Subscribing to and handling of update events
  10. class HelloWorld : public Sample
  11. {
  12. URHO3D_OBJECT(HelloWorld, Sample);
  13. public:
  14. /// Construct.
  15. explicit HelloWorld(Context* context);
  16. /// Setup after engine initialization and before running the main loop.
  17. void Start() override;
  18. protected:
  19. /// Return XML patch instructions for screen joystick layout for a specific sample app, if any.
  20. String GetScreenJoystickPatchString() const override { return
  21. "<patch>"
  22. " <add sel=\"/element/element[./attribute[@name='Name' and @value='Hat0']]\">"
  23. " <attribute name=\"Is Visible\" value=\"false\" />"
  24. " </add>"
  25. "</patch>";
  26. }
  27. private:
  28. /// Construct a new Text instance, containing the 'Hello World' String, and add it to the UI root element.
  29. void CreateText();
  30. /// Subscribe to application-wide logic update events.
  31. void SubscribeToEvents();
  32. /// Handle the logic update event.
  33. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  34. };