Skip to content
0.2.0-dev Download ZIP
124 lines ·6.8 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="AnimatedSprite3D" inherits="SpriteBase3D" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 2D sprite node in 3D world, that can use multiple 2D textures for animation.
5 </brief_description>
6 <description>
7 [AnimatedSprite3D] is similar to the [Sprite3D] node, except it carries multiple textures as animation [member sprite_frames]. Animations are created using a [SpriteFrames] resource, which allows you to import image files (or a folder containing said files) to provide the animation frames for the sprite. The [SpriteFrames] resource can be configured in the editor via the SpriteFrames bottom panel.
8 </description>
9 <tutorials>
10 <link title="2D Sprite animation (also applies to 3D)">$DOCS_URL/tutorials/2d/2d_sprite_animation.html</link>
11 </tutorials>
12 <methods>
13 <method name="get_playing_speed" qualifiers="const">
14 <return type="float" />
15 <description>
16 Returns the actual playing speed of current animation or [code]0[/code] if not playing. This speed is the [member speed_scale] property multiplied by [code]custom_speed[/code] argument specified when calling the [method play] method.
17 Returns a negative value if the current animation is playing backwards.
18 </description>
19 </method>
20 <method name="is_playing" qualifiers="const">
21 <return type="bool" />
22 <description>
23 Returns [code]true[/code] if an animation is currently playing (even if [member speed_scale] and/or [code]custom_speed[/code] are [code]0[/code]).
24 </description>
25 </method>
26 <method name="pause">
27 <return type="void" />
28 <description>
29 Pauses the currently playing animation. The [member frame] and [member frame_progress] will be kept and calling [method play] or [method play_backwards] without arguments will resume the animation from the current playback position.
30 See also [method stop].
31 </description>
32 </method>
33 <method name="play">
34 <return type="void" />
35 <param index="0" name="name" type="StringName" default="&amp;&quot;&quot;" />
36 <param index="1" name="custom_speed" type="float" default="1.0" />
37 <param index="2" name="from_end" type="bool" default="false" />
38 <description>
39 Plays the animation with key [param name]. If [param custom_speed] is negative and [param from_end] is [code]true[/code], the animation will play backwards (which is equivalent to calling [method play_backwards]).
40 If this method is called with that same animation [param name], or with no [param name] parameter, the assigned animation will resume playing if it was paused.
41 </description>
42 </method>
43 <method name="play_backwards">
44 <return type="void" />
45 <param index="0" name="name" type="StringName" default="&amp;&quot;&quot;" />
46 <description>
47 Plays the animation with key [param name] in reverse.
48 This method is a shorthand for [method play] with [code]custom_speed = -1.0[/code] and [code]from_end = true[/code], so see its description for more information.
49 </description>
50 </method>
51 <method name="set_frame_and_progress">
52 <return type="void" />
53 <param index="0" name="frame" type="int" />
54 <param index="1" name="progress" type="float" />
55 <description>
56 Sets [member frame] and [member frame_progress] to the given values. Unlike setting [member frame], this method does not reset the [member frame_progress] to [code]0.0[/code] implicitly.
57 [b]Example:[/b] Change the animation while keeping the same [member frame] and [member frame_progress]:
58 [codeblocks]
59 [gdscript]
60 var current_frame = animated_sprite.get_frame()
61 var current_progress = animated_sprite.get_frame_progress()
62 animated_sprite.play("walk_another_skin")
63 animated_sprite.set_frame_and_progress(current_frame, current_progress)
64 [/gdscript]
65 [/codeblocks]
66 </description>
67 </method>
68 <method name="stop">
69 <return type="void" />
70 <description>
71 Stops the currently playing animation. The animation position is reset to [code]0[/code] and the [code]custom_speed[/code] is reset to [code]1.0[/code]. See also [method pause].
72 </description>
73 </method>
74 </methods>
75 <members>
76 <member name="animation" type="StringName" setter="set_animation" getter="get_animation" default="&amp;&quot;default&quot;">
77 The current animation from the [member sprite_frames] resource. If this value is changed, the [member frame] counter and the [member frame_progress] are reset.
78 </member>
79 <member name="autoplay" type="String" setter="set_autoplay" getter="get_autoplay" default="&quot;&quot;">
80 The key of the animation to play when the scene loads.
81 </member>
82 <member name="frame" type="int" setter="set_frame" getter="get_frame" default="0">
83 The displayed animation frame's index. Setting this property also resets [member frame_progress]. If this is not desired, use [method set_frame_and_progress].
84 </member>
85 <member name="frame_progress" type="float" setter="set_frame_progress" getter="get_frame_progress" default="0.0">
86 The progress value between [code]0.0[/code] and [code]1.0[/code] until the current frame transitions to the next frame. If the animation is playing backwards, the value transitions from [code]1.0[/code] to [code]0.0[/code].
87 </member>
88 <member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale" default="1.0">
89 The speed scaling ratio. For example, if this value is [code]1[/code], then the animation plays at normal speed. If it's [code]0.5[/code], then it plays at half speed. If it's [code]2[/code], then it plays at double speed.
90 If set to a negative value, the animation is played in reverse. If set to [code]0[/code], the animation will not advance.
91 </member>
92 <member name="sprite_frames" type="SpriteFrames" setter="set_sprite_frames" getter="get_sprite_frames">
93 The [SpriteFrames] resource containing the animation(s). Allows you the option to load, edit, clear, make unique and save the states of the [SpriteFrames] resource.
94 </member>
95 </members>
96 <signals>
97 <signal name="animation_changed">
98 <description>
99 Emitted when [member animation] changes.
100 </description>
101 </signal>
102 <signal name="animation_finished">
103 <description>
104 Emitted when the animation reaches the end, or the start if it is played in reverse. When the animation finishes, it pauses the playback.
105 [b]Note:[/b] This signal is not emitted if an animation is looping.
106 </description>
107 </signal>
108 <signal name="animation_looped">
109 <description>
110 Emitted when the animation loops.
111 </description>
112 </signal>
113 <signal name="frame_changed">
114 <description>
115 Emitted when [member frame] changes.
116 </description>
117 </signal>
118 <signal name="sprite_frames_changed">
119 <description>
120 Emitted when [member sprite_frames] changes.
121 </description>
122 </signal>
123 </signals>
124</class>