animations-properties.rst 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. .. include:: ../_header.rst
  2. Animation properties
  3. --------------------
  4. The animation properties section contains the parameters of the `play() <https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Sprite.html#play__anchor>`_ method of the `Sprite <sprite-object.html>`_ game object:
  5. .. image:: ../images/scene-editor-animations-props-20231027.webp
  6. :alt: Animation properties
  7. The **Action** parameter indicates what method execute to play the animation:
  8. * **NONE** (default): Doesn't call any method, doesn't play any animation.
  9. * **PLAY**: Calls the `play()`_ method.
  10. * **PLAY_REVERSE**: Calls the `playReverse() <https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Sprite.html#playReverse__anchor>`_ method.
  11. .. image:: ../images/scene-editor-animations-props-action-param.webp
  12. :alt: Select the Phaser API method to play the animation.
  13. The **Animation Key** parameter contains the key of the animation to play:
  14. .. image:: ../images/scene-editor-animations-props-animation-key-param-20231027.webp
  15. :alt: Animation Key parameter.
  16. Next to the key name, there are two buttons. A button for opening an animation key selection dialog and a button for previewing the selected animation.
  17. The animation key selection dialog:
  18. .. image:: ../images/prefab-user-props-animation-key-dialog-20231027.webp
  19. :alt: A dialog for selecting the animation key.
  20. The animation preview dialog:
  21. .. image:: ../images/prefab-user-props-animation-key-preview-dialog-20231027.webp
  22. :alt: Animation key preview.
  23. This dialog searches for animations defined in a `Phaser animations file <../animations-editor/>`_ or in the Aseprite_ assets included in an |AssetPackFile|_.
  24. This is the code the |SceneCompiler|_ generates for playing the animation:
  25. .. code::
  26. dragon.play("dragon - dragon/Moving Forward");
  27. Or, if you select the **PLAY_REVERSE** action:
  28. .. code::
  29. dragon.playReverse("dragon - dragon/Moving Forward");
  30. When you define the animations in the |AnimationsEditor|_ or in Aseprite_, you configure parameters like repetitions, duration, direction, etc... However, in the scene, you can pass a custom configuration to the `play()`_ method. To do this in the |SceneEditor|_ you have to check the **Custom Config** parameter.
  31. If the **Custom Config** parameter is selected, then it shows the **Animation Configuration** section. It shows all the parameters you can set to an animation:
  32. .. image:: ../images/scene-editor-animations-props-custom-config-20231027.webp
  33. :alt: Custom configuration.
  34. When you set the custom configuration, the |SceneCompiler|_ generates this code:
  35. .. code::
  36. dragon.play({
  37. "key": "dragon - dragon/Moving Forward"
  38. "frameRate": 10,
  39. "repeat": -1
  40. });