class_sprite.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. | void | :ref:`set_texture<class_Sprite_set_texture>` **(** :ref:`Texture<class_texture>` texture **)** |
  15. +--------------------------------+---------------------------------------------------------------------------------------------------+
  16. | :ref:`Texture<class_texture>` | :ref:`get_texture<class_Sprite_get_texture>` **(** **)** const |
  17. +--------------------------------+---------------------------------------------------------------------------------------------------+
  18. | void | :ref:`set_centered<class_Sprite_set_centered>` **(** :ref:`bool<class_bool>` centered **)** |
  19. +--------------------------------+---------------------------------------------------------------------------------------------------+
  20. | :ref:`bool<class_bool>` | :ref:`is_centered<class_Sprite_is_centered>` **(** **)** const |
  21. +--------------------------------+---------------------------------------------------------------------------------------------------+
  22. | void | :ref:`set_offset<class_Sprite_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  23. +--------------------------------+---------------------------------------------------------------------------------------------------+
  24. | :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_Sprite_get_offset>` **(** **)** const |
  25. +--------------------------------+---------------------------------------------------------------------------------------------------+
  26. | void | :ref:`set_flip_h<class_Sprite_set_flip_h>` **(** :ref:`bool<class_bool>` flip_h **)** |
  27. +--------------------------------+---------------------------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`is_flipped_h<class_Sprite_is_flipped_h>` **(** **)** const |
  29. +--------------------------------+---------------------------------------------------------------------------------------------------+
  30. | void | :ref:`set_flip_v<class_Sprite_set_flip_v>` **(** :ref:`bool<class_bool>` flip_v **)** |
  31. +--------------------------------+---------------------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`is_flipped_v<class_Sprite_is_flipped_v>` **(** **)** const |
  33. +--------------------------------+---------------------------------------------------------------------------------------------------+
  34. | void | :ref:`set_region<class_Sprite_set_region>` **(** :ref:`bool<class_bool>` enabled **)** |
  35. +--------------------------------+---------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`is_region<class_Sprite_is_region>` **(** **)** const |
  37. +--------------------------------+---------------------------------------------------------------------------------------------------+
  38. | void | :ref:`set_region_rect<class_Sprite_set_region_rect>` **(** :ref:`Rect2<class_rect2>` rect **)** |
  39. +--------------------------------+---------------------------------------------------------------------------------------------------+
  40. | :ref:`Rect2<class_rect2>` | :ref:`get_region_rect<class_Sprite_get_region_rect>` **(** **)** const |
  41. +--------------------------------+---------------------------------------------------------------------------------------------------+
  42. | void | :ref:`set_frame<class_Sprite_set_frame>` **(** :ref:`int<class_int>` frame **)** |
  43. +--------------------------------+---------------------------------------------------------------------------------------------------+
  44. | :ref:`int<class_int>` | :ref:`get_frame<class_Sprite_get_frame>` **(** **)** const |
  45. +--------------------------------+---------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_vframes<class_Sprite_set_vframes>` **(** :ref:`int<class_int>` vframes **)** |
  47. +--------------------------------+---------------------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`get_vframes<class_Sprite_get_vframes>` **(** **)** const |
  49. +--------------------------------+---------------------------------------------------------------------------------------------------+
  50. | void | :ref:`set_hframes<class_Sprite_set_hframes>` **(** :ref:`int<class_int>` hframes **)** |
  51. +--------------------------------+---------------------------------------------------------------------------------------------------+
  52. | :ref:`int<class_int>` | :ref:`get_hframes<class_Sprite_get_hframes>` **(** **)** const |
  53. +--------------------------------+---------------------------------------------------------------------------------------------------+
  54. | void | :ref:`set_modulate<class_Sprite_set_modulate>` **(** :ref:`Color<class_color>` modulate **)** |
  55. +--------------------------------+---------------------------------------------------------------------------------------------------+
  56. | :ref:`Color<class_color>` | :ref:`get_modulate<class_Sprite_get_modulate>` **(** **)** const |
  57. +--------------------------------+---------------------------------------------------------------------------------------------------+
  58. Signals
  59. -------
  60. - **frame_changed** **(** **)**
  61. Description
  62. -----------
  63. 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.
  64. Member Function Description
  65. ---------------------------
  66. .. _class_Sprite_set_texture:
  67. - void **set_texture** **(** :ref:`Texture<class_texture>` texture **)**
  68. Set the base texture for the sprite.
  69. .. _class_Sprite_get_texture:
  70. - :ref:`Texture<class_texture>` **get_texture** **(** **)** const
  71. Return the base texture for the sprite.
  72. .. _class_Sprite_set_centered:
  73. - void **set_centered** **(** :ref:`bool<class_bool>` centered **)**
  74. Set whether the sprite should be centered on the origin.
  75. .. _class_Sprite_is_centered:
  76. - :ref:`bool<class_bool>` **is_centered** **(** **)** const
  77. Return if the sprite is centered at the local origin.
  78. .. _class_Sprite_set_offset:
  79. - void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  80. Set the sprite draw offset, useful for setting rotation pivots.
  81. .. _class_Sprite_get_offset:
  82. - :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
  83. Return sprite draw offset.
  84. .. _class_Sprite_set_flip_h:
  85. - void **set_flip_h** **(** :ref:`bool<class_bool>` flip_h **)**
  86. Set true to flip the sprite horizontally.
  87. .. _class_Sprite_is_flipped_h:
  88. - :ref:`bool<class_bool>` **is_flipped_h** **(** **)** const
  89. Return true if the sprite is flipped horizontally.
  90. .. _class_Sprite_set_flip_v:
  91. - void **set_flip_v** **(** :ref:`bool<class_bool>` flip_v **)**
  92. Set true to flip the sprite vertically.
  93. .. _class_Sprite_is_flipped_v:
  94. - :ref:`bool<class_bool>` **is_flipped_v** **(** **)** const
  95. Return true if the sprite is flipped vertically.
  96. .. _class_Sprite_set_region:
  97. - void **set_region** **(** :ref:`bool<class_bool>` enabled **)**
  98. Set the sprite as a sub-region of a bigger texture. Useful for texture-atlases.
  99. .. _class_Sprite_is_region:
  100. - :ref:`bool<class_bool>` **is_region** **(** **)** const
  101. Return if the sprite reads from a region.
  102. .. _class_Sprite_set_region_rect:
  103. - void **set_region_rect** **(** :ref:`Rect2<class_rect2>` rect **)**
  104. Set the region rect to read from.
  105. .. _class_Sprite_get_region_rect:
  106. - :ref:`Rect2<class_rect2>` **get_region_rect** **(** **)** const
  107. Return the region rect to read from.
  108. .. _class_Sprite_set_frame:
  109. - void **set_frame** **(** :ref:`int<class_int>` frame **)**
  110. Set the texture frame for a sprite-sheet, works when vframes or hframes are greater than 1.
  111. .. _class_Sprite_get_frame:
  112. - :ref:`int<class_int>` **get_frame** **(** **)** const
  113. Return the texture frame for a sprite-sheet, works when vframes or hframes are greater than 1.
  114. .. _class_Sprite_set_vframes:
  115. - void **set_vframes** **(** :ref:`int<class_int>` vframes **)**
  116. Set the amount of vertical frames and converts the sprite into a sprite-sheet. This is useful for animation.
  117. .. _class_Sprite_get_vframes:
  118. - :ref:`int<class_int>` **get_vframes** **(** **)** const
  119. Return the amount of vertical frames. See :ref:`set_vframes<class_Sprite_set_vframes>`.
  120. .. _class_Sprite_set_hframes:
  121. - void **set_hframes** **(** :ref:`int<class_int>` hframes **)**
  122. Set the amount of horizontal frames and converts the sprite into a sprite-sheet. This is useful for animation.
  123. .. _class_Sprite_get_hframes:
  124. - :ref:`int<class_int>` **get_hframes** **(** **)** const
  125. Return the amount of horizontal frames. See :ref:`set_hframes<class_Sprite_set_hframes>`.
  126. .. _class_Sprite_set_modulate:
  127. - void **set_modulate** **(** :ref:`Color<class_color>` modulate **)**
  128. 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.
  129. .. _class_Sprite_get_modulate:
  130. - :ref:`Color<class_color>` **get_modulate** **(** **)** const
  131. Return color modulation for the sprite. All sprite pixels are multiplied by this color.