animations.rst 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .. _doc_animations:
  2. Animations
  3. ==========
  4. Introduction
  5. ------------
  6. Godot's animation system is extremely powerful and flexible.
  7. To begin, let's use the scene from the previous tutorial (:ref:`doc_splash_screen`).
  8. The goal is to add a "fade-in" animation to the splash image. Here's a copy
  9. just in case: :download:`robisplash.zip <files/robisplash.zip>`.
  10. Add an animation player
  11. -----------------------
  12. First of all, add an :ref:`AnimationPlayer <class_AnimationPlayer>`
  13. node to the scene as a child of "background" (the root node):
  14. .. image:: img/robisplash_anim_inspector.png
  15. When a node of this type is selected, the animation editor panel will
  16. appear:
  17. .. image:: img/robisplash_anim_editor.png
  18. The animation editor panel stays visible until manually hidden.
  19. Creating the animation
  20. ----------------------
  21. It's time to create a new animation! Press the new animation button and name
  22. the animation "intro" when the dialog appears.
  23. .. image:: img/robisplash_anim_new.png
  24. Now that we have an animation the property editor enters
  25. "animation editing" mode. In this mode, a key icon appears next to
  26. every property of the property editor. In Godot any property of an object
  27. can be animated:
  28. .. image:: img/robisplash_anim_property_keys.png
  29. Editing the animation
  30. ---------------------
  31. The logo will appear from the top of the screen.
  32. With the animation editor panel open, select the "logo" node and set the
  33. "Rect / Position" property to ``(118, -400)`` and press the key button next
  34. to the property:
  35. .. image:: img/robisplash_anim_logo_inspector_key.png
  36. When the dialog appears, confirm that you are creating a new track.
  37. The keyframe will be added in the animation player editor:
  38. .. image:: img/robisplash_anim_editor_keyframe.png
  39. Move the editor cursor to the end by clicking here:
  40. .. image:: img/robisplash_anim_editor_track_cursor.png
  41. Change the logo position to ``(118, 0)`` and add a keyframe again. With two
  42. keyframes, the animation happens.
  43. .. image:: img/robisplash_anim_editor_keyframe_2.png
  44. Pressing "Play selected animation from start. (Shift-D)" on the animation panel
  45. will make the logo descend.
  46. .. image:: img/robisplash_anim_editor_play_start.png
  47. Click the "Autoplay on Load" button to set the animation to start automatically
  48. when the scene starts.
  49. .. image:: img/robisplash_anim_editor_autoplay.png
  50. And finally, when running the scene, the animation should look like
  51. this:
  52. .. image:: img/out.gif