summaryrefslogtreecommitdiff
path: root/doc/classes/SpriteFrames.xml
blob: 87b823bd2a706ac8e308069748dfebb2f390d1da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?xml version="1.0" encoding="UTF-8" ?>
<class name="SpriteFrames" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
	<brief_description>
		Sprite frame library for AnimatedSprite2D and AnimatedSprite3D.
	</brief_description>
	<description>
		Sprite frame library for an [AnimatedSprite2D] or [AnimatedSprite3D] node. Contains frames and animation data for playback.
		[b]Note:[/b] You can associate a set of normal or specular maps by creating additional [SpriteFrames] resources with a [code]_normal[/code] or [code]_specular[/code] suffix. For example, having 3 [SpriteFrames] resources [code]run[/code], [code]run_normal[/code], and [code]run_specular[/code] will make it so the [code]run[/code] animation uses normal and specular maps.
	</description>
	<tutorials>
	</tutorials>
	<methods>
		<method name="add_animation">
			<return type="void" />
			<param index="0" name="anim" type="StringName" />
			<description>
				Adds a new animation to the library.
			</description>
		</method>
		<method name="add_frame">
			<return type="void" />
			<param index="0" name="anim" type="StringName" />
			<param index="1" name="texture" type="Texture2D" />
			<param index="2" name="duration" type="float" default="1.0" />
			<param index="3" name="at_position" type="int" default="-1" />
			<description>
				Adds a frame to the given animation.
			</description>
		</method>
		<method name="clear">
			<return type="void" />
			<param index="0" name="anim" type="StringName" />
			<description>
				Removes all frames from the given animation.
			</description>
		</method>
		<method name="clear_all">
			<return type="void" />
			<description>
				Removes all animations. A "default" animation will be created.
			</description>
		</method>
		<method name="get_animation_loop" qualifiers="const">
			<return type="bool" />
			<param index="0" name="anim" type="StringName" />
			<description>
				Returns [code]true[/code] if the given animation is configured to loop when it finishes playing. Otherwise, returns [code]false[/code].
			</description>
		</method>
		<method name="get_animation_names" qualifiers="const">
			<return type="PackedStringArray" />
			<description>
				Returns an array containing the names associated to each animation. Values are placed in alphabetical order.
			</description>
		</method>
		<method name="get_animation_speed" qualifiers="const">
			<return type="float" />
			<param index="0" name="anim" type="StringName" />
			<description>
				Returns the speed in frames per second for the [param anim] animation.
			</description>
		</method>
		<method name="get_frame_count" qualifiers="const">
			<return type="int" />
			<param index="0" name="anim" type="StringName" />
			<description>
				Returns the number of frames for the [param anim] animation.
			</description>
		</method>
		<method name="get_frame_duration" qualifiers="const">
			<return type="float" />
			<param index="0" name="anim" type="StringName" />
			<param index="1" name="idx" type="int" />
			<description>
				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:
				[codeblock]
				absolute_duration = relative_duration / (animation_fps * abs(speed_scale))
				[/codeblock]
				In this example, [code]speed_scale[/code] refers to either [member AnimatedSprite2D.speed_scale] or [member AnimatedSprite3D.speed_scale].
			</description>
		</method>
		<method name="get_frame_texture" qualifiers="const">
			<return type="Texture2D" />
			<param index="0" name="anim" type="StringName" />
			<param index="1" name="idx" type="int" />
			<description>
				Returns the texture of the frame [param idx] in the [param anim] animation.
			</description>
		</method>
		<method name="has_animation" qualifiers="const">
			<return type="bool" />
			<param index="0" name="anim" type="StringName" />
			<description>
				If [code]true[/code], the named animation exists.
			</description>
		</method>
		<method name="remove_animation">
			<return type="void" />
			<param index="0" name="anim" type="StringName" />
			<description>
				Removes the given animation.
			</description>
		</method>
		<method name="remove_frame">
			<return type="void" />
			<param index="0" name="anim" type="StringName" />
			<param index="1" name="idx" type="int" />
			<description>
				Removes the animation's selected frame.
			</description>
		</method>
		<method name="rename_animation">
			<return type="void" />
			<param index="0" name="anim" type="StringName" />
			<param index="1" name="newname" type="StringName" />
			<description>
				Changes the animation's name to [param newname].
			</description>
		</method>
		<method name="set_animation_loop">
			<return type="void" />
			<param index="0" name="anim" type="StringName" />
			<param index="1" name="loop" type="bool" />
			<description>
				If [code]true[/code], the animation will loop.
			</description>
		</method>
		<method name="set_animation_speed">
			<return type="void" />
			<param index="0" name="anim" type="StringName" />
			<param index="1" name="fps" type="float" />
			<description>
				Sets the speed for the [param anim] animation in frames per second.
			</description>
		</method>
		<method name="set_frame">
			<return type="void" />
			<param index="0" name="anim" type="StringName" />
			<param index="1" name="idx" type="int" />
			<param index="2" name="texture" type="Texture2D" />
			<param index="3" name="duration" type="float" default="1.0" />
			<description>
				Sets the texture and the duration of the frame [param idx] in the [param anim] animation.
			</description>
		</method>
	</methods>
</class>