class_sprite.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Sprite:
  4. Sprite
  5. ======
  6. **Inherits:** :ref:`Node2D<class_node2d>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. General purpose Sprite node.
  11. Member Functions
  12. ----------------
  13. +--------------------------------+---------------------------------------------------------------------------------------------------+
  14. | :ref:`int<class_int>` | :ref:`get_frame<class_Sprite_get_frame>` **(** **)** const |
  15. +--------------------------------+---------------------------------------------------------------------------------------------------+
  16. | :ref:`int<class_int>` | :ref:`get_hframes<class_Sprite_get_hframes>` **(** **)** const |
  17. +--------------------------------+---------------------------------------------------------------------------------------------------+
  18. | :ref:`Color<class_color>` | :ref:`get_modulate<class_Sprite_get_modulate>` **(** **)** const |
  19. +--------------------------------+---------------------------------------------------------------------------------------------------+
  20. | :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_Sprite_get_offset>` **(** **)** const |
  21. +--------------------------------+---------------------------------------------------------------------------------------------------+
  22. | :ref:`Rect2<class_rect2>` | :ref:`get_region_rect<class_Sprite_get_region_rect>` **(** **)** const |
  23. +--------------------------------+---------------------------------------------------------------------------------------------------+
  24. | :ref:`Texture<class_texture>` | :ref:`get_texture<class_Sprite_get_texture>` **(** **)** const |
  25. +--------------------------------+---------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`get_vframes<class_Sprite_get_vframes>` **(** **)** const |
  27. +--------------------------------+---------------------------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`is_centered<class_Sprite_is_centered>` **(** **)** const |
  29. +--------------------------------+---------------------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`is_flipped_h<class_Sprite_is_flipped_h>` **(** **)** const |
  31. +--------------------------------+---------------------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`is_flipped_v<class_Sprite_is_flipped_v>` **(** **)** const |
  33. +--------------------------------+---------------------------------------------------------------------------------------------------+
  34. | :ref:`bool<class_bool>` | :ref:`is_region<class_Sprite_is_region>` **(** **)** const |
  35. +--------------------------------+---------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_centered<class_Sprite_set_centered>` **(** :ref:`bool<class_bool>` centered **)** |
  37. +--------------------------------+---------------------------------------------------------------------------------------------------+
  38. | void | :ref:`set_flip_h<class_Sprite_set_flip_h>` **(** :ref:`bool<class_bool>` flip_h **)** |
  39. +--------------------------------+---------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_flip_v<class_Sprite_set_flip_v>` **(** :ref:`bool<class_bool>` flip_v **)** |
  41. +--------------------------------+---------------------------------------------------------------------------------------------------+
  42. | void | :ref:`set_frame<class_Sprite_set_frame>` **(** :ref:`int<class_int>` frame **)** |
  43. +--------------------------------+---------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_hframes<class_Sprite_set_hframes>` **(** :ref:`int<class_int>` hframes **)** |
  45. +--------------------------------+---------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_modulate<class_Sprite_set_modulate>` **(** :ref:`Color<class_color>` modulate **)** |
  47. +--------------------------------+---------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_offset<class_Sprite_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  49. +--------------------------------+---------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_region<class_Sprite_set_region>` **(** :ref:`bool<class_bool>` enabled **)** |
  51. +--------------------------------+---------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_region_rect<class_Sprite_set_region_rect>` **(** :ref:`Rect2<class_rect2>` rect **)** |
  53. +--------------------------------+---------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_texture<class_Sprite_set_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  55. +--------------------------------+---------------------------------------------------------------------------------------------------+
  56. | void | :ref:`set_vframes<class_Sprite_set_vframes>` **(** :ref:`int<class_int>` vframes **)** |
  57. +--------------------------------+---------------------------------------------------------------------------------------------------+
  58. Signals
  59. -------
  60. - **frame_changed** **(** **)**
  61. - **texture_changed** **(** **)**
  62. Description
  63. -----------
  64. General purpose Sprite node. This Sprite node can show any texture as a sprite. The texture can be used as a spritesheet for animation, or only a region from a bigger texture can referenced, like an atlas.
  65. Member Function Description
  66. ---------------------------
  67. .. _class_Sprite_get_frame:
  68. - :ref:`int<class_int>` **get_frame** **(** **)** const
  69. Return the texture frame for a sprite-sheet, works when vframes or hframes are greater than 1.
  70. .. _class_Sprite_get_hframes:
  71. - :ref:`int<class_int>` **get_hframes** **(** **)** const
  72. Return the amount of horizontal frames. See :ref:`set_hframes<class_Sprite_set_hframes>`.
  73. .. _class_Sprite_get_modulate:
  74. - :ref:`Color<class_color>` **get_modulate** **(** **)** const
  75. Return color modulation for the sprite. All sprite pixels are multiplied by this color.
  76. .. _class_Sprite_get_offset:
  77. - :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
  78. Return sprite draw offset.
  79. .. _class_Sprite_get_region_rect:
  80. - :ref:`Rect2<class_rect2>` **get_region_rect** **(** **)** const
  81. Return the region rect to read from.
  82. .. _class_Sprite_get_texture:
  83. - :ref:`Texture<class_texture>` **get_texture** **(** **)** const
  84. Return the base texture for the sprite.
  85. .. _class_Sprite_get_vframes:
  86. - :ref:`int<class_int>` **get_vframes** **(** **)** const
  87. Return the amount of vertical frames. See :ref:`set_vframes<class_Sprite_set_vframes>`.
  88. .. _class_Sprite_is_centered:
  89. - :ref:`bool<class_bool>` **is_centered** **(** **)** const
  90. Return if the sprite is centered at the local origin.
  91. .. _class_Sprite_is_flipped_h:
  92. - :ref:`bool<class_bool>` **is_flipped_h** **(** **)** const
  93. Return true if the sprite is flipped horizontally.
  94. .. _class_Sprite_is_flipped_v:
  95. - :ref:`bool<class_bool>` **is_flipped_v** **(** **)** const
  96. Return true if the sprite is flipped vertically.
  97. .. _class_Sprite_is_region:
  98. - :ref:`bool<class_bool>` **is_region** **(** **)** const
  99. Return if the sprite reads from a region.
  100. .. _class_Sprite_set_centered:
  101. - void **set_centered** **(** :ref:`bool<class_bool>` centered **)**
  102. Set whether the sprite should be centered on the origin.
  103. .. _class_Sprite_set_flip_h:
  104. - void **set_flip_h** **(** :ref:`bool<class_bool>` flip_h **)**
  105. Set true to flip the sprite horizontally.
  106. .. _class_Sprite_set_flip_v:
  107. - void **set_flip_v** **(** :ref:`bool<class_bool>` flip_v **)**
  108. Set true to flip the sprite vertically.
  109. .. _class_Sprite_set_frame:
  110. - void **set_frame** **(** :ref:`int<class_int>` frame **)**
  111. Set the texture frame for a sprite-sheet, works when vframes or hframes are greater than 1.
  112. .. _class_Sprite_set_hframes:
  113. - void **set_hframes** **(** :ref:`int<class_int>` hframes **)**
  114. Set the amount of horizontal frames and converts the sprite into a sprite-sheet. This is useful for animation.
  115. .. _class_Sprite_set_modulate:
  116. - void **set_modulate** **(** :ref:`Color<class_color>` modulate **)**
  117. Set color modulation for the sprite. All sprite pixels are multiplied by this color. Color may contain rgb values above 1 to achieve a highlight effect.
  118. .. _class_Sprite_set_offset:
  119. - void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  120. Set the sprite draw offset, useful for setting rotation pivots.
  121. .. _class_Sprite_set_region:
  122. - void **set_region** **(** :ref:`bool<class_bool>` enabled **)**
  123. Set the sprite as a sub-region of a bigger texture. Useful for texture-atlases.
  124. .. _class_Sprite_set_region_rect:
  125. - void **set_region_rect** **(** :ref:`Rect2<class_rect2>` rect **)**
  126. Set the region rect to read from.
  127. .. _class_Sprite_set_texture:
  128. - void **set_texture** **(** :ref:`Texture<class_texture>` texture **)**
  129. Set the base texture for the sprite.
  130. .. _class_Sprite_set_vframes:
  131. - void **set_vframes** **(** :ref:`int<class_int>` vframes **)**
  132. Set the amount of vertical frames and converts the sprite into a sprite-sheet. This is useful for animation.