You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/2d/2d_sprite_animation.rst
+39-25Lines changed: 39 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,12 +7,16 @@ Introduction
7
7
------------
8
8
9
9
In this tutorial, you'll learn how to create 2D animated
10
-
characters with the AnimatedSprite2D class and the AnimationPlayer. Typically, when you create or download an animated character, it
11
-
will come in one of two ways: as individual images or as a single sprite sheet
12
-
containing all the animation's frames. Both can be animated in Godot with the AnimatedSprite2D class.
10
+
characters with the AnimatedSprite2D class and the AnimationPlayer.
11
+
Typically, when you create or download an animated character,
12
+
it will come in one of two ways: as individual images or as a single sprite sheet
13
+
containing all the animation's frames.
14
+
Both can be animated in Godot with the AnimatedSprite2D class.
13
15
14
16
First, we'll use :ref:`AnimatedSprite2D <class_AnimatedSprite2D>` to
15
-
animate a collection of individual images. Then we will animate a sprite sheet using this class. Finally, we will learn another way to animate a sprite sheet
17
+
animate a collection of individual images.
18
+
Then we will animate a sprite sheet using this class.
19
+
Finally, we will learn another way to animate a sprite sheet
16
20
with :ref:`AnimationPlayer <class_AnimationPlayer>` and the *Animation*
17
21
property of :ref:`Sprite2D <class_Sprite2D>`.
18
22
@@ -45,7 +49,7 @@ with the following nodes:
45
49
Now select the ``AnimatedSprite2D`` and in its *SpriteFrames* property, select
46
50
"New SpriteFrames".
47
51
48
-
.. image:: img/2d_animation_new_spriteframes.png
52
+
.. image:: img/2d_animation_new_spriteframes.webp
49
53
50
54
Click on the new SpriteFrames resource and you'll see a new panel appear at the
51
55
bottom of the editor window:
@@ -58,11 +62,12 @@ of the animation from "default" to "run".
Back in the Inspector, check the box for the *Playing* property. You should
62
-
now see the animation playing in the viewport. However, it is a bit slow. To
63
-
fix this, change the *Speed (FPS)* setting in the SpriteFrames panel to 10.
65
+
Use the "Play" buttons on the top-right of the *Filter Animations* input to preview the animation.
66
+
You should now see the animation playing in the viewport.
67
+
However, it is a bit slow. To fix this,
68
+
change the *Speed (FPS)* setting in the SpriteFrames panel to 10.
64
69
65
-
You can add additional animations by clicking the "New Animation" button and
70
+
You can add additional animations by clicking the "Add Animation" button and
66
71
adding additional images.
67
72
68
73
Controlling the animation
@@ -116,30 +121,37 @@ released.
116
121
Sprite sheet with AnimatedSprite2D
117
122
----------------------------------
118
123
119
-
You can also easily animate from a sprite sheet with the class ``AnimatedSprite2D``. We will use this public domain sprite sheet:
124
+
You can also easily animate from a sprite sheet with the class ``AnimatedSprite2D``.
125
+
We will use this public domain sprite sheet:
120
126
121
127
.. image:: img/2d_animation_frog_spritesheet.png
122
128
123
-
Right-click the image and choose "Save Image As" to download it, and then copy the image into your project folder.
129
+
Right-click the image and choose "Save Image As" to download it,
130
+
and then copy the image into your project folder.
124
131
125
-
Set up your scene tree the same way you did previously when using individual images. Select the ``AnimatedSprite2D`` and in its *SpriteFrames* property, select
126
-
"New SpriteFrames".
132
+
Set up your scene tree the same way you did previously when using individual images.
133
+
Select the ``AnimatedSprite2D`` and in its *SpriteFrames* property, select "New SpriteFrames".
127
134
128
-
Click on the new SpriteFrames resource. This time, when the bottom panel appears, select "Add frames from a Sprite Sheet".
135
+
Click on the new SpriteFrames resource.
136
+
This time, when the bottom panel appears, select "Add frames from a Sprite Sheet".
You will be prompted to open a file. Select your sprite sheet.
133
141
134
-
A new window will open, showing your sprite sheet. The first thing you will need to do is to change the number of vertical and horizontal images in your sprite sheet. In this sprite sheet, we have four images horizontally and two images vertically.
142
+
A new window will open, showing your sprite sheet.
143
+
The first thing you will need to do is to change the number of vertical and horizontal images in your sprite sheet.
144
+
In this sprite sheet, we have four images horizontally and two images vertically.
Next, select the frames from the sprite sheet that you want to include in your animation. We will select the top four, then click "Add 4 frames" to create the animation.
148
+
Next, select the frames from the sprite sheet that you want to include in your animation.
149
+
We will select the top four, then click "Add 4 frames" to create the animation.
@@ -180,7 +192,7 @@ expand the *Animation* section in the Inspector and set the *Hframes* to ``6``.
180
192
*Hframes* and *Vframes* are the number of horizontal and vertical frames in
181
193
your sprite sheet.
182
194
183
-
.. image:: img/2d_animation_setframes.png
195
+
.. image:: img/2d_animation_setframes.webp
184
196
185
197
Now try changing the value of the *Frame* property. You'll see that it ranges
186
198
from ``0`` to ``5`` and the image displayed by the Sprite2D changes accordingly.
@@ -190,17 +202,17 @@ Select the ``AnimationPlayer`` and click the "Animation" button followed by
190
202
"New". Name the new animation "walk". Set the animation length to ``0.6`` and
191
203
click the "Loop" button so that our animation will repeat.
192
204
193
-
.. image:: img/2d_animation_new_animation.png
205
+
.. image:: img/2d_animation_new_animation.webp
194
206
195
207
Now select the ``Sprite2D`` node and click the key icon to add a new track.
196
208
197
-
.. image:: img/2d_animation_new_track.png
209
+
.. image:: img/2d_animation_new_track.webp
198
210
199
211
Continue adding frames at each point in the timeline (``0.1`` seconds by
200
212
default), until you have all the frames from 0 to 5. You'll see the frames
201
213
actually appearing in the animation track:
202
214
203
-
.. image:: img/2d_animation_full_animation.png
215
+
.. image:: img/2d_animation_full_animation.webp
204
216
205
217
Press "Play" on the animation to see how it looks.
206
218
@@ -266,7 +278,9 @@ released.
266
278
Summary
267
279
-------
268
280
269
-
These examples illustrate the two classes you can use in Godot for
270
-
2D animation. ``AnimationPlayer`` is
271
-
a bit more complex than ``AnimatedSprite2D``, but it provides additional functionality, since you can also
272
-
animate other properties like position or scale. The class ``AnimationPlayer`` can also be used with an ``AnimatedSprite2D``. Experiment to see what works best for your needs.
281
+
These examples illustrate the two classes you can use in Godot for 2D animation.
282
+
``AnimationPlayer`` is a bit more complex than ``AnimatedSprite2D``,
283
+
but it provides additional functionality, since you can also
284
+
animate other properties like position or scale.
285
+
The class ``AnimationPlayer`` can also be used with an ``AnimatedSprite2D``.
0 commit comments