animations.rst 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. Animations
  2. ==========
  3. Introduction
  4. ------------
  5. This tutorial will explain how everything is animated in Godot. Godot
  6. animation system is extremely powerful and flexible.
  7. To begin, let's just use the scene from the previous tutorial (splash
  8. screen). The goal will be to add a simple animation to it. Here's a copy
  9. just in case: attachment:robisplash.zip
  10. Creating the Animation
  11. ----------------------
  12. First of all, add an
  13. `AnimationPlayer <https://github.com/okamstudio/godot/wiki/class_animationplayer>`__
  14. node to the scene, make it 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, then 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.
  30. .. image:: /img/animeditor.png
  31. But the second, and most important, is that the property editor enters
  32. into "animation editing" mode. In this mode, a key icon appears next to
  33. every property of the property editor. This means that, in Godot, *any
  34. property of any object* can be animated:
  35. .. image:: /img/propertykeys.png
  36. Making the Logo Appear
  37. ----------------------
  38. | Next, the logo will appear from the top of the screen. After selecting
  39. the animation player, the editor panel will stay visible until
  40. manually hidden (or the animation node is erased). Taking advantage of
  41. this, select the "logo" node and go to the "pos" property, move it up,
  42. to position: 114,-400.
  43. | Once in this position, press the key button next to the property:
  44. .. image:: /img/keypress.png
  45. As the track is new, a dialog will appear asking to create it. Confirm
  46. it!
  47. .. image:: /img/addtrack.png
  48. And the keyframe will be added in the animation player editor:
  49. .. image:: /img/keyadded.png
  50. Second, move the editor cursor to the end, by clicking here:
  51. .. image:: /img/move_cursor.png
  52. Change the logo position to 114,0 and a keyframe again. With two
  53. keyframes, the animation happens.
  54. .. image:: /img/animation.png
  55. Pressing Play on the animation panel will make the logo descend. To test
  56. it by running the scene, the autoplay button can tag the animation to
  57. start automatically when the scene starts:
  58. .. image:: /img/autoplay.png
  59. And finally, when running the scene, the animation should look like
  60. this:
  61. .. image:: /img/out.gif
  62. *Juan Linietsky, Ariel Manzur, Distributed under the terms of the `CC
  63. By <https://creativecommons.org/licenses/by/3.0/legalcode>`__ license.*