class_sprite.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Sprite.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Sprite:
  5. Sprite
  6. ======
  7. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. General purpose Sprite node.
  12. Member Functions
  13. ----------------
  14. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`get_frame<class_Sprite_get_frame>` **(** **)** const |
  16. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`int<class_int>` | :ref:`get_hframes<class_Sprite_get_hframes>` **(** **)** const |
  18. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Texture<class_texture>` | :ref:`get_normal_map<class_Sprite_get_normal_map>` **(** **)** const |
  20. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_Sprite_get_offset>` **(** **)** const |
  22. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Rect2<class_rect2>` | :ref:`get_region_rect<class_Sprite_get_region_rect>` **(** **)** const |
  24. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`Texture<class_texture>` | :ref:`get_texture<class_Sprite_get_texture>` **(** **)** const |
  26. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`int<class_int>` | :ref:`get_vframes<class_Sprite_get_vframes>` **(** **)** const |
  28. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`is_centered<class_Sprite_is_centered>` **(** **)** const |
  30. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`is_flipped_h<class_Sprite_is_flipped_h>` **(** **)** const |
  32. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`is_flipped_v<class_Sprite_is_flipped_v>` **(** **)** const |
  34. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`is_region<class_Sprite_is_region>` **(** **)** const |
  36. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`is_region_filter_clip_enabled<class_Sprite_is_region_filter_clip_enabled>` **(** **)** const |
  38. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_centered<class_Sprite_set_centered>` **(** :ref:`bool<class_bool>` centered **)** |
  40. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_flip_h<class_Sprite_set_flip_h>` **(** :ref:`bool<class_bool>` flip_h **)** |
  42. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`set_flip_v<class_Sprite_set_flip_v>` **(** :ref:`bool<class_bool>` flip_v **)** |
  44. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_frame<class_Sprite_set_frame>` **(** :ref:`int<class_int>` frame **)** |
  46. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`set_hframes<class_Sprite_set_hframes>` **(** :ref:`int<class_int>` hframes **)** |
  48. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`set_normal_map<class_Sprite_set_normal_map>` **(** :ref:`Texture<class_texture>` normal_map **)** |
  50. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`set_offset<class_Sprite_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  52. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`set_region<class_Sprite_set_region>` **(** :ref:`bool<class_bool>` enabled **)** |
  54. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`set_region_filter_clip<class_Sprite_set_region_filter_clip>` **(** :ref:`bool<class_bool>` enabled **)** |
  56. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`set_region_rect<class_Sprite_set_region_rect>` **(** :ref:`Rect2<class_rect2>` rect **)** |
  58. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`set_texture<class_Sprite_set_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  60. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_vframes<class_Sprite_set_vframes>` **(** :ref:`int<class_int>` vframes **)** |
  62. +--------------------------------+------------------------------------------------------------------------------------------------------------------+
  63. Signals
  64. -------
  65. - **frame_changed** **(** **)**
  66. Emitted when the member frame changes.
  67. - **texture_changed** **(** **)**
  68. Emitted when the member texture changes.
  69. Member Variables
  70. ----------------
  71. - :ref:`bool<class_bool>` **centered** - If ``true`` texture is centered. Default value: ``true``.
  72. - :ref:`bool<class_bool>` **flip_h** - If ``true`` texture is flipped horizontally. Default value: ``false``.
  73. - :ref:`bool<class_bool>` **flip_v** - If ``true`` texture is flipped vertically. Default value: ``false``.
  74. - :ref:`int<class_int>` **frame** - Current frame to display from sprite sheet. member vframes or member hframes must be greater than 1.
  75. - :ref:`int<class_int>` **hframes** - The number of collumns in the sprite sheet.
  76. - :ref:`Texture<class_texture>` **normal_map** - The normal map gives depth to the Sprite.
  77. - :ref:`Vector2<class_vector2>` **offset** - The texture's drawing offset.
  78. - :ref:`bool<class_bool>` **region_enabled** - If ``true`` texture is cut from a larger atlas texture. See ``region_rect``. Default value: ``false``.
  79. - :ref:`bool<class_bool>` **region_filter_clip** - If ``true`` the outermost pixels get blurred out.
  80. - :ref:`Rect2<class_rect2>` **region_rect** - The region of the atlas texture to display. member region_enabled must be ``true``.
  81. - :ref:`Texture<class_texture>` **texture** - :ref:`Texture<class_texture>` object to draw.
  82. - :ref:`int<class_int>` **vframes** - The number of rows in the sprite sheet.
  83. Description
  84. -----------
  85. A node that displays a 2D texture. The texture displayed can be a region from a larger atlas texture, or a frame from a sprite sheet animation.
  86. Member Function Description
  87. ---------------------------
  88. .. _class_Sprite_get_frame:
  89. - :ref:`int<class_int>` **get_frame** **(** **)** const
  90. Return the texture frame for a sprite-sheet, works when vframes or hframes are greater than 1.
  91. .. _class_Sprite_get_hframes:
  92. - :ref:`int<class_int>` **get_hframes** **(** **)** const
  93. Return the amount of horizontal frames. See :ref:`set_hframes<class_Sprite_set_hframes>`.
  94. .. _class_Sprite_get_normal_map:
  95. - :ref:`Texture<class_texture>` **get_normal_map** **(** **)** const
  96. .. _class_Sprite_get_offset:
  97. - :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
  98. Return sprite draw offset.
  99. .. _class_Sprite_get_region_rect:
  100. - :ref:`Rect2<class_rect2>` **get_region_rect** **(** **)** const
  101. Return the region rect to read from.
  102. .. _class_Sprite_get_texture:
  103. - :ref:`Texture<class_texture>` **get_texture** **(** **)** const
  104. Return the base texture for the sprite.
  105. .. _class_Sprite_get_vframes:
  106. - :ref:`int<class_int>` **get_vframes** **(** **)** const
  107. Return the amount of vertical frames. See :ref:`set_vframes<class_Sprite_set_vframes>`.
  108. .. _class_Sprite_is_centered:
  109. - :ref:`bool<class_bool>` **is_centered** **(** **)** const
  110. Return if the sprite is centered at the local origin.
  111. .. _class_Sprite_is_flipped_h:
  112. - :ref:`bool<class_bool>` **is_flipped_h** **(** **)** const
  113. Return true if the sprite is flipped horizontally.
  114. .. _class_Sprite_is_flipped_v:
  115. - :ref:`bool<class_bool>` **is_flipped_v** **(** **)** const
  116. Return true if the sprite is flipped vertically.
  117. .. _class_Sprite_is_region:
  118. - :ref:`bool<class_bool>` **is_region** **(** **)** const
  119. Return if the sprite reads from a region.
  120. .. _class_Sprite_is_region_filter_clip_enabled:
  121. - :ref:`bool<class_bool>` **is_region_filter_clip_enabled** **(** **)** const
  122. .. _class_Sprite_set_centered:
  123. - void **set_centered** **(** :ref:`bool<class_bool>` centered **)**
  124. Set whether the sprite should be centered on the origin.
  125. .. _class_Sprite_set_flip_h:
  126. - void **set_flip_h** **(** :ref:`bool<class_bool>` flip_h **)**
  127. Set true to flip the sprite horizontally.
  128. .. _class_Sprite_set_flip_v:
  129. - void **set_flip_v** **(** :ref:`bool<class_bool>` flip_v **)**
  130. Set true to flip the sprite vertically.
  131. .. _class_Sprite_set_frame:
  132. - void **set_frame** **(** :ref:`int<class_int>` frame **)**
  133. Set the texture frame for a sprite-sheet, works when vframes or hframes are greater than 1.
  134. .. _class_Sprite_set_hframes:
  135. - void **set_hframes** **(** :ref:`int<class_int>` hframes **)**
  136. Set the amount of horizontal frames and converts the sprite into a sprite-sheet. This is useful for animation.
  137. .. _class_Sprite_set_normal_map:
  138. - void **set_normal_map** **(** :ref:`Texture<class_texture>` normal_map **)**
  139. .. _class_Sprite_set_offset:
  140. - void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  141. Set the sprite draw offset, useful for setting rotation pivots.
  142. .. _class_Sprite_set_region:
  143. - void **set_region** **(** :ref:`bool<class_bool>` enabled **)**
  144. Set the sprite as a sub-region of a bigger texture. Useful for texture-atlases.
  145. .. _class_Sprite_set_region_filter_clip:
  146. - void **set_region_filter_clip** **(** :ref:`bool<class_bool>` enabled **)**
  147. .. _class_Sprite_set_region_rect:
  148. - void **set_region_rect** **(** :ref:`Rect2<class_rect2>` rect **)**
  149. Set the region rect to read from.
  150. .. _class_Sprite_set_texture:
  151. - void **set_texture** **(** :ref:`Texture<class_texture>` texture **)**
  152. Set the base texture for the sprite.
  153. .. _class_Sprite_set_vframes:
  154. - void **set_vframes** **(** :ref:`int<class_int>` vframes **)**
  155. Set the amount of vertical frames and converts the sprite into a sprite-sheet. This is useful for animation.