class_animatedsprite.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the AnimatedSprite.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_AnimatedSprite:
  5. AnimatedSprite
  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. Sprite node that can use multiple textures for animation.
  12. Member Functions
  13. ----------------
  14. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  15. | :ref:`String<class_string>` | :ref:`get_animation<class_AnimatedSprite_get_animation>` **(** **)** const |
  16. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  17. | :ref:`int<class_int>` | :ref:`get_frame<class_AnimatedSprite_get_frame>` **(** **)** const |
  18. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  19. | :ref:`Vector2<class_vector2>` | :ref:`get_offset<class_AnimatedSprite_get_offset>` **(** **)** const |
  20. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`SpriteFrames<class_spriteframes>` | :ref:`get_sprite_frames<class_AnimatedSprite_get_sprite_frames>` **(** **)** const |
  22. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`bool<class_bool>` | :ref:`is_centered<class_AnimatedSprite_is_centered>` **(** **)** const |
  24. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`bool<class_bool>` | :ref:`is_flipped_h<class_AnimatedSprite_is_flipped_h>` **(** **)** const |
  26. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`is_flipped_v<class_AnimatedSprite_is_flipped_v>` **(** **)** const |
  28. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`is_playing<class_AnimatedSprite_is_playing>` **(** **)** const |
  30. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`play<class_AnimatedSprite_play>` **(** :ref:`String<class_string>` anim="" **)** |
  32. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`set_animation<class_AnimatedSprite_set_animation>` **(** :ref:`String<class_string>` animation **)** |
  34. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`set_centered<class_AnimatedSprite_set_centered>` **(** :ref:`bool<class_bool>` centered **)** |
  36. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`set_flip_h<class_AnimatedSprite_set_flip_h>` **(** :ref:`bool<class_bool>` flip_h **)** |
  38. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_flip_v<class_AnimatedSprite_set_flip_v>` **(** :ref:`bool<class_bool>` flip_v **)** |
  40. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_frame<class_AnimatedSprite_set_frame>` **(** :ref:`int<class_int>` frame **)** |
  42. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`set_offset<class_AnimatedSprite_set_offset>` **(** :ref:`Vector2<class_vector2>` offset **)** |
  44. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`set_sprite_frames<class_AnimatedSprite_set_sprite_frames>` **(** :ref:`SpriteFrames<class_spriteframes>` sprite_frames **)** |
  46. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`stop<class_AnimatedSprite_stop>` **(** **)** |
  48. +------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  49. Signals
  50. -------
  51. - **animation_finished** **(** **)**
  52. Emitted when the animation is finished (when it plays the last frame). If the animation is looping, this signal is emitted every time the last frame is drawn.
  53. - **frame_changed** **(** **)**
  54. Emitted when member frame changed.
  55. Member Variables
  56. ----------------
  57. - :ref:`String<class_string>` **animation** - The current animation from the ``frames`` resource. If this value changes, the ``frame`` counter is reset.
  58. - :ref:`bool<class_bool>` **centered** - If ``true`` texture will be centered. Default value: ``true``.
  59. - :ref:`bool<class_bool>` **flip_h** - If ``true`` texture is flipped horizontally. Default value: ``false``.
  60. - :ref:`bool<class_bool>` **flip_v** - If ``true`` texture is flipped vertically. Default value: ``false``.
  61. - :ref:`int<class_int>` **frame** - The displayed animation frame's index.
  62. - :ref:`SpriteFrames<class_spriteframes>` **frames** - The :ref:`SpriteFrames<class_spriteframes>` resource containing the animation(s).
  63. - :ref:`Vector2<class_vector2>` **offset** - The texture's drawing offset.
  64. - :ref:`bool<class_bool>` **playing** - If ``true`` the member animation is currently playing.
  65. Description
  66. -----------
  67. Animations are created using a :ref:`SpriteFrames<class_spriteframes>` resource, which can be configured in the editor via the SpriteFrames panel.
  68. Member Function Description
  69. ---------------------------
  70. .. _class_AnimatedSprite_get_animation:
  71. - :ref:`String<class_string>` **get_animation** **(** **)** const
  72. Return the name of the current animation set to the node.
  73. .. _class_AnimatedSprite_get_frame:
  74. - :ref:`int<class_int>` **get_frame** **(** **)** const
  75. Return the visible frame index.
  76. .. _class_AnimatedSprite_get_offset:
  77. - :ref:`Vector2<class_vector2>` **get_offset** **(** **)** const
  78. Return the offset of the sprite in the node origin.
  79. .. _class_AnimatedSprite_get_sprite_frames:
  80. - :ref:`SpriteFrames<class_spriteframes>` **get_sprite_frames** **(** **)** const
  81. Get the :ref:`SpriteFrames<class_spriteframes>` resource, which contains all frames.
  82. .. _class_AnimatedSprite_is_centered:
  83. - :ref:`bool<class_bool>` **is_centered** **(** **)** const
  84. Return true when centered. See :ref:`set_centered<class_AnimatedSprite_set_centered>`.
  85. .. _class_AnimatedSprite_is_flipped_h:
  86. - :ref:`bool<class_bool>` **is_flipped_h** **(** **)** const
  87. Return true if sprite is flipped horizontally.
  88. .. _class_AnimatedSprite_is_flipped_v:
  89. - :ref:`bool<class_bool>` **is_flipped_v** **(** **)** const
  90. Return true if sprite is flipped vertically.
  91. .. _class_AnimatedSprite_is_playing:
  92. - :ref:`bool<class_bool>` **is_playing** **(** **)** const
  93. Return true if an animation if currently being played.
  94. .. _class_AnimatedSprite_play:
  95. - void **play** **(** :ref:`String<class_string>` anim="" **)**
  96. Play the animation set in parameter. If no parameter is provided, the current animation is played.
  97. .. _class_AnimatedSprite_set_animation:
  98. - void **set_animation** **(** :ref:`String<class_string>` animation **)**
  99. Set the current animation of the node and reinits the frame counter of the animation.
  100. .. _class_AnimatedSprite_set_centered:
  101. - void **set_centered** **(** :ref:`bool<class_bool>` centered **)**
  102. When turned on, offset at (0,0) is the center of the sprite, when off, the top-left corner is.
  103. .. _class_AnimatedSprite_set_flip_h:
  104. - void **set_flip_h** **(** :ref:`bool<class_bool>` flip_h **)**
  105. If true, sprite is flipped horizontally.
  106. .. _class_AnimatedSprite_set_flip_v:
  107. - void **set_flip_v** **(** :ref:`bool<class_bool>` flip_v **)**
  108. If true, sprite is flipped vertically.
  109. .. _class_AnimatedSprite_set_frame:
  110. - void **set_frame** **(** :ref:`int<class_int>` frame **)**
  111. Set the visible sprite frame index (from the list of frames inside the :ref:`SpriteFrames<class_spriteframes>` resource).
  112. .. _class_AnimatedSprite_set_offset:
  113. - void **set_offset** **(** :ref:`Vector2<class_vector2>` offset **)**
  114. Set the offset of the sprite in the node origin. Position varies depending on whether it is centered or not.
  115. .. _class_AnimatedSprite_set_sprite_frames:
  116. - void **set_sprite_frames** **(** :ref:`SpriteFrames<class_spriteframes>` sprite_frames **)**
  117. Set the :ref:`SpriteFrames<class_spriteframes>` resource, which contains all frames.
  118. .. _class_AnimatedSprite_stop:
  119. - void **stop** **(** **)**
  120. Stop the current animation (does not reset the frame counter).