| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="SpriteFrames" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Sprite frame library for AnimatedSprite2D and AnimatedSprite3D. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | Sprite frame library for an [AnimatedSprite2D] or [AnimatedSprite3D] node. Contains frames and animation data for playback. |
| 8 | </description> |
| 9 | <tutorials> |
| 10 | </tutorials> |
| 11 | <methods> |
| 12 | <method name="add_animation"> |
| 13 | <return type="void" /> |
| 14 | <param index="0" name="anim" type="StringName" /> |
| 15 | <description> |
| 16 | Adds a new [param anim] animation to the library. |
| 17 | </description> |
| 18 | </method> |
| 19 | <method name="add_frame"> |
| 20 | <return type="void" /> |
| 21 | <param index="0" name="anim" type="StringName" /> |
| 22 | <param index="1" name="texture" type="Texture2D" /> |
| 23 | <param index="2" name="duration" type="float" default="1.0" /> |
| 24 | <param index="3" name="at_position" type="int" default="-1" /> |
| 25 | <description> |
| 26 | Adds a frame to the [param anim] animation. If [param at_position] is [code]-1[/code], the frame will be added to the end of the animation. [param duration] specifies the relative duration, see [method get_frame_duration] for details. |
| 27 | </description> |
| 28 | </method> |
| 29 | <method name="clear"> |
| 30 | <return type="void" /> |
| 31 | <param index="0" name="anim" type="StringName" /> |
| 32 | <description> |
| 33 | Removes all frames from the [param anim] animation. |
| 34 | </description> |
| 35 | </method> |
| 36 | <method name="clear_all"> |
| 37 | <return type="void" /> |
| 38 | <description> |
| 39 | Removes all animations. An empty [code]default[/code] animation will be created. |
| 40 | </description> |
| 41 | </method> |
| 42 | <method name="duplicate_animation"> |
| 43 | <return type="void" /> |
| 44 | <param index="0" name="anim_from" type="StringName" /> |
| 45 | <param index="1" name="anim_to" type="StringName" /> |
| 46 | <description> |
| 47 | Duplicates the animation [param anim_from] to a new animation named [param anim_to]. Fails if [param anim_to] already exists, or if [param anim_from] does not exist. |
| 48 | </description> |
| 49 | </method> |
| 50 | <method name="get_animation_loop" qualifiers="const"> |
| 51 | <return type="bool" /> |
| 52 | <param index="0" name="anim" type="StringName" /> |
| 53 | <description> |
| 54 | Returns [code]true[/code] if the given animation is configured to loop when it finishes playing. Otherwise, returns [code]false[/code]. |
| 55 | </description> |
| 56 | </method> |
| 57 | <method name="get_animation_names" qualifiers="const"> |
| 58 | <return type="PackedStringArray" /> |
| 59 | <description> |
| 60 | Returns an array containing the names associated to each animation. Values are placed in alphabetical order. |
| 61 | </description> |
| 62 | </method> |
| 63 | <method name="get_animation_speed" qualifiers="const"> |
| 64 | <return type="float" /> |
| 65 | <param index="0" name="anim" type="StringName" /> |
| 66 | <description> |
| 67 | Returns the speed in frames per second for the [param anim] animation. |
| 68 | </description> |
| 69 | </method> |
| 70 | <method name="get_frame_count" qualifiers="const"> |
| 71 | <return type="int" /> |
| 72 | <param index="0" name="anim" type="StringName" /> |
| 73 | <description> |
| 74 | Returns the number of frames for the [param anim] animation. |
| 75 | </description> |
| 76 | </method> |
| 77 | <method name="get_frame_duration" qualifiers="const"> |
| 78 | <return type="float" /> |
| 79 | <param index="0" name="anim" type="StringName" /> |
| 80 | <param index="1" name="idx" type="int" /> |
| 81 | <description> |
| 82 | Returns a relative duration of the frame [param idx] in the [param anim] animation (defaults to [code]1.0[/code]). For example, a frame with a duration of [code]2.0[/code] is displayed twice as long as a frame with a duration of [code]1.0[/code]. You can calculate the absolute duration (in seconds) of a frame using the following formula: |
| 83 | [codeblock] |
| 84 | absolute_duration = relative_duration / (animation_fps * abs(playing_speed)) |
| 85 | [/codeblock] |
| 86 | In this example, [code]playing_speed[/code] refers to either [method AnimatedSprite2D.get_playing_speed] or [method AnimatedSprite3D.get_playing_speed]. |
| 87 | </description> |
| 88 | </method> |
| 89 | <method name="get_frame_texture" qualifiers="const"> |
| 90 | <return type="Texture2D" /> |
| 91 | <param index="0" name="anim" type="StringName" /> |
| 92 | <param index="1" name="idx" type="int" /> |
| 93 | <description> |
| 94 | Returns the texture of the frame [param idx] in the [param anim] animation. |
| 95 | </description> |
| 96 | </method> |
| 97 | <method name="has_animation" qualifiers="const"> |
| 98 | <return type="bool" /> |
| 99 | <param index="0" name="anim" type="StringName" /> |
| 100 | <description> |
| 101 | Returns [code]true[/code] if the [param anim] animation exists. |
| 102 | </description> |
| 103 | </method> |
| 104 | <method name="remove_animation"> |
| 105 | <return type="void" /> |
| 106 | <param index="0" name="anim" type="StringName" /> |
| 107 | <description> |
| 108 | Removes the [param anim] animation. |
| 109 | </description> |
| 110 | </method> |
| 111 | <method name="remove_frame"> |
| 112 | <return type="void" /> |
| 113 | <param index="0" name="anim" type="StringName" /> |
| 114 | <param index="1" name="idx" type="int" /> |
| 115 | <description> |
| 116 | Removes the [param anim] animation's frame [param idx]. |
| 117 | </description> |
| 118 | </method> |
| 119 | <method name="rename_animation"> |
| 120 | <return type="void" /> |
| 121 | <param index="0" name="anim" type="StringName" /> |
| 122 | <param index="1" name="newname" type="StringName" /> |
| 123 | <description> |
| 124 | Changes the [param anim] animation's name to [param newname]. |
| 125 | </description> |
| 126 | </method> |
| 127 | <method name="set_animation_loop"> |
| 128 | <return type="void" /> |
| 129 | <param index="0" name="anim" type="StringName" /> |
| 130 | <param index="1" name="loop" type="bool" /> |
| 131 | <description> |
| 132 | If [param loop] is [code]true[/code], the [param anim] animation will loop when it reaches the end, or the start if it is played in reverse. |
| 133 | </description> |
| 134 | </method> |
| 135 | <method name="set_animation_speed"> |
| 136 | <return type="void" /> |
| 137 | <param index="0" name="anim" type="StringName" /> |
| 138 | <param index="1" name="fps" type="float" /> |
| 139 | <description> |
| 140 | Sets the speed for the [param anim] animation in frames per second. |
| 141 | </description> |
| 142 | </method> |
| 143 | <method name="set_frame"> |
| 144 | <return type="void" /> |
| 145 | <param index="0" name="anim" type="StringName" /> |
| 146 | <param index="1" name="idx" type="int" /> |
| 147 | <param index="2" name="texture" type="Texture2D" /> |
| 148 | <param index="3" name="duration" type="float" default="1.0" /> |
| 149 | <description> |
| 150 | Sets the [param texture] and the [param duration] of the frame [param idx] in the [param anim] animation. [param duration] specifies the relative duration, see [method get_frame_duration] for details. |
| 151 | </description> |
| 152 | </method> |
| 153 | </methods> |
| 154 | </class> |