sprite.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*************************************************************************/
  2. /* sprite.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef SPRITE_H
  31. #define SPRITE_H
  32. #include "scene/2d/node_2d.h"
  33. #include "scene/resources/texture.h"
  34. class Sprite : public Node2D {
  35. GDCLASS(Sprite, Node2D);
  36. Ref<Texture> texture;
  37. Ref<Texture> normal_map;
  38. bool centered;
  39. Point2 offset;
  40. bool hflip;
  41. bool vflip;
  42. bool region;
  43. Rect2 region_rect;
  44. bool region_filter_clip;
  45. int frame;
  46. int vframes;
  47. int hframes;
  48. protected:
  49. void _notification(int p_what);
  50. static void _bind_methods();
  51. virtual void _validate_property(PropertyInfo &property) const;
  52. public:
  53. virtual void edit_set_pivot(const Point2 &p_pivot);
  54. virtual Point2 edit_get_pivot() const;
  55. virtual bool edit_has_pivot() const;
  56. void set_texture(const Ref<Texture> &p_texture);
  57. Ref<Texture> get_texture() const;
  58. void set_normal_map(const Ref<Texture> &p_texture);
  59. Ref<Texture> get_normal_map() const;
  60. void set_centered(bool p_center);
  61. bool is_centered() const;
  62. void set_offset(const Point2 &p_offset);
  63. Point2 get_offset() const;
  64. void set_flip_h(bool p_flip);
  65. bool is_flipped_h() const;
  66. void set_flip_v(bool p_flip);
  67. bool is_flipped_v() const;
  68. void set_region(bool p_region);
  69. bool is_region() const;
  70. void set_region_filter_clip(bool p_enable);
  71. bool is_region_filter_clip_enabled() const;
  72. void set_region_rect(const Rect2 &p_region_rect);
  73. Rect2 get_region_rect() const;
  74. void set_frame(int p_frame);
  75. int get_frame() const;
  76. void set_vframes(int p_amount);
  77. int get_vframes() const;
  78. void set_hframes(int p_amount);
  79. int get_hframes() const;
  80. virtual Rect2 get_item_rect() const;
  81. Sprite();
  82. };
  83. #if 0
  84. class ViewportSprite : public Node2D {
  85. GDCLASS( ViewportSprite, Node2D );
  86. Ref<Texture> texture;
  87. NodePath viewport_path;
  88. bool centered;
  89. Point2 offset;
  90. Color modulate;
  91. protected:
  92. void _notification(int p_what);
  93. static void _bind_methods();
  94. public:
  95. virtual void edit_set_pivot(const Point2& p_pivot);
  96. virtual Point2 edit_get_pivot() const;
  97. virtual bool edit_has_pivot() const;
  98. void set_viewport_path(const NodePath& p_viewport);
  99. NodePath get_viewport_path() const;
  100. void set_centered(bool p_center);
  101. bool is_centered() const;
  102. void set_offset(const Point2& p_offset);
  103. Point2 get_offset() const;
  104. void set_modulate(const Color& p_color);
  105. Color get_modulate() const;
  106. virtual Rect2 get_item_rect() const;
  107. virtual String get_configuration_warning() const;
  108. ViewportSprite();
  109. };
  110. #endif
  111. #endif // SPRITE_H