Urho2DIsometricDemo.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "Sample.h"
  5. #include "Utilities2D/Sample2D.h"
  6. class Character2D;
  7. class Sample2D;
  8. /// Tile map example.
  9. /// This sample demonstrates:
  10. /// - Creating an isometric 2D scene with tile map
  11. /// - Displaying the scene using the Renderer subsystem
  12. /// - Handling keyboard to move a character and zoom 2D camera
  13. /// - Generating physics shapes from the tmx file's objects
  14. /// - Displaying debug geometry for physics and tile map
  15. /// Note that this sample uses some functions from Sample2D utility class.
  16. class Urho2DIsometricDemo : public Sample
  17. {
  18. URHO3D_OBJECT(Urho2DIsometricDemo, Sample);
  19. public:
  20. /// Construct.
  21. explicit Urho2DIsometricDemo(Context* context);
  22. /// Setup after engine initialization and before running the main loop.
  23. void Start() override;
  24. /// Setup before engine initialization. Modifies the engine parameters.
  25. void Setup() override;
  26. private:
  27. /// Construct the scene content.
  28. void CreateScene();
  29. /// Construct an instruction text to the UI.
  30. void CreateInstructions();
  31. /// Subscribe to application-wide logic update events.
  32. void SubscribeToEvents();
  33. /// Handle the logic update event.
  34. void HandleUpdate(StringHash eventType, VariantMap& eventData);
  35. /// Handle the logic post update event.
  36. void HandlePostUpdate(StringHash eventType, VariantMap& eventData);
  37. /// Handle the post render update event.
  38. void HandlePostRenderUpdate(StringHash eventType, VariantMap& eventData);
  39. /// Handle the end rendering event.
  40. void HandleSceneRendered(StringHash eventType, VariantMap& eventData);
  41. /// Handle reloading the scene.
  42. void ReloadScene(bool reInit);
  43. /// Handle the contact begin event (Box2D contact listener).
  44. void HandleCollisionBegin(StringHash eventType, VariantMap& eventData);
  45. /// Handle 'PLAY' button released event.
  46. void HandlePlayButton(StringHash eventType, VariantMap& eventData);
  47. /// The controllable character component.
  48. WeakPtr<Character2D> character2D_;
  49. /// Camera's zoom (used to scale movement speed based on camera zoom).
  50. float zoom_;
  51. /// Flag for drawing debug geometry.
  52. bool drawDebug_;
  53. /// Sample2D utility object.
  54. SharedPtr<Sample2D> sample2D_;
  55. };