animations.rst 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 Animation button then select
  22. new from the menu. Name the animation "intro" when the dialog appears.
  23. .. image:: img/robisplash_anim_button.png
  24. .. image:: img/robisplash_anim_new.png
  25. Now that we have an animation, the property editor enters
  26. "animation editing" mode. In this mode, a key icon appears next to
  27. every property of the property editor. In Godot, any property of an object
  28. can be animated:
  29. .. image:: img/robisplash_anim_property_keys.png
  30. Editing the animation
  31. ---------------------
  32. The logo will appear from the top of the screen.
  33. With the animation editor panel open, select the "logo" node and set the
  34. "Rect / Position" property to ``(118, -400)`` and press the key button next
  35. to the property to add a keyframe:
  36. .. image:: img/robisplash_anim_logo_inspector_key.png
  37. When the dialog appears, confirm that you are creating a new track.
  38. The keyframe will be added in the animation player editor:
  39. .. image:: img/robisplash_anim_editor_keyframe.png
  40. Move the editor cursor forward in time by clicking here:
  41. .. image:: img/robisplash_anim_editor_track_cursor.png
  42. Change the logo position to ``(118, 0)`` and add a keyframe again. With two
  43. keyframes with different values, the animation happens.
  44. .. image:: img/robisplash_anim_editor_keyframe_2.png
  45. Pressing "Play selected animation from start" button on the animation panel (or :kbd:`Shift + D` on keyboard)
  46. will make the logo descend.
  47. .. image:: img/robisplash_anim_editor_play_start.png
  48. Click the "Autoplay on Load" button to set the animation to start automatically
  49. when the scene starts.
  50. .. image:: img/robisplash_anim_editor_autoplay.png
  51. And finally, when running the scene, the animation should look like
  52. this:
  53. .. image:: img/out.gif