animations.rst 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. .. _doc_animations:
  2. Animations
  3. ==========
  4. Introduction
  5. ------------
  6. This tutorial will explain how everything is animated in Godot. Godot's
  7. animation system is extremely powerful and flexible.
  8. To begin, let's just use the scene from the previous tutorial (:ref:`doc_splash_screen`).
  9. The goal is, to add a simple animation to it. Here's a copy
  10. just in case: :download:`robisplash.zip </files/robisplash.zip>`.
  11. Creating the animation
  12. ----------------------
  13. First of all, add an :ref:`AnimationPlayer <class_AnimationPlayer>`
  14. node to the scene as a child of "bg" (the root node):
  15. .. image:: /img/animplayer.png
  16. When a node of this type is selected, the animation editor panel will
  17. appear:
  18. .. image:: /img/animpanel.png
  19. So, it's time to create a new animation! Press the new animation button
  20. and name the animation "intro".
  21. .. image:: /img/animnew.png
  22. After the animation has been created, it's time to edit it, by
  23. pressing the "edit" button:
  24. .. image:: /img/animedit.png
  25. Editing the animation
  26. ---------------------
  27. Now this is when the magic happens! Several things happen when the
  28. "edit" button is pressed, the first one is that the animation editor
  29. appears above the animation panel. (In Godot 2.x, this button has been
  30. removed, instead, click on the 'animation' toggle at the bottom right
  31. for similar functionality.)
  32. .. image:: /img/animeditor.png
  33. The second and most important, is that the property editor enters
  34. "animation editing" mode. In this mode, a key icon appears next to
  35. every property of the property editor. This means that, in Godot, *any
  36. property of any object* can be animated:
  37. .. image:: /img/propertykeys.png
  38. Making the logo appear
  39. ----------------------
  40. The logo will appear from the top of the screen. After selecting
  41. the animation player, the editor panel will stay visible until
  42. manually hidden (or the animation node is erased). Taking advantage of
  43. this, select the "logo" node and go to the "pos" property, move it up
  44. to position: 114,-400.
  45. Once in this position, press the key button next to the property:
  46. .. image:: /img/keypress.png
  47. As the track is new, a dialog will appear asking to create it. Confirm
  48. it!
  49. .. image:: /img/addtrack.png
  50. The keyframe will be added in the animation player editor:
  51. .. image:: /img/keyadded.png
  52. Move the editor cursor to the end, by clicking here:
  53. .. image:: /img/move_cursor.png
  54. Change the logo position to 114,0 and add a keyframe again. With two
  55. keyframes, the animation happens.
  56. .. image:: /img/animation.png
  57. Pressing Play on the animation panel will make the logo descend. To test
  58. it by running the scene, the autoplay button can tag the animation to
  59. start automatically when the scene starts:
  60. .. image:: /img/autoplay.png
  61. And finally, when running the scene, the animation should look like
  62. this:
  63. .. image:: /img/out.gif