StaticSprite2D.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // Copyright (c) 2008-2014 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "Drawable2D.h"
  24. namespace Urho3D
  25. {
  26. class Sprite2D;
  27. /// Static sprite component.
  28. class URHO3D_API StaticSprite2D : public Drawable2D
  29. {
  30. OBJECT(StaticSprite2D);
  31. public:
  32. /// Construct.
  33. StaticSprite2D(Context* context);
  34. /// Destruct.
  35. ~StaticSprite2D();
  36. /// Register object factory. Drawable2D must be registered first.
  37. static void RegisterObject(Context* context);
  38. /// Set sprite.
  39. void SetSprite(Sprite2D* sprite);
  40. /// Set flip.
  41. void SetFlip(bool flipX, bool flipY);
  42. /// Set flip X.
  43. void SetFlipX(bool flipX);
  44. /// Set flip Y.
  45. void SetFlipY(bool flipY);
  46. /// Set color.
  47. void SetColor(const Color& color);
  48. /// Set use hot spot.
  49. void SetUseHotSpot(bool useHotSpot);
  50. /// Set hot spot.
  51. void SetHotSpot(const Vector2& hotspot);
  52. /// Return sprite.
  53. Sprite2D* GetSprite() const;
  54. /// Return flip X.
  55. bool GetFlipX() const { return flipX_; }
  56. /// Return flip Y.
  57. bool GetFlipY() const { return flipY_; }
  58. /// Return color.
  59. const Color& GetColor() const { return color_; }
  60. /// Return use hot spot.
  61. bool GetUseHotSpot() const { return useHotSpot_; }
  62. /// Return hot spot.
  63. const Vector2& GetHotSpot() const { return hotSpot_; }
  64. /// Set sprite attribute.
  65. void SetSpriteAttr(const ResourceRef& value);
  66. /// Return sprite attribute.
  67. ResourceRef GetSpriteAttr() const;
  68. protected:
  69. /// Recalculate the world-space bounding box.
  70. virtual void OnWorldBoundingBoxUpdate();
  71. /// Update vertices.
  72. virtual void UpdateVertices();
  73. /// Sprite.
  74. SharedPtr<Sprite2D> sprite_;
  75. /// Flip X.
  76. bool flipX_;
  77. /// Flip Y.
  78. bool flipY_;
  79. /// Color.
  80. Color color_;
  81. /// Use hot spot.
  82. bool useHotSpot_;
  83. /// Hot spot.
  84. Vector2 hotSpot_;
  85. };
  86. }