diff --git a/spine-ts/spine-webgl/example/webcomponent-tutorial.html b/spine-ts/spine-webgl/example/webcomponent-tutorial.html index 21431c454..dd69b12f7 100644 --- a/spine-ts/spine-webgl/example/webcomponent-tutorial.html +++ b/spine-ts/spine-webgl/example/webcomponent-tutorial.html @@ -633,6 +633,307 @@ ///////////////////// --> + + +
+ +
+
+

To change animation, we could also just change the animation attribute. The widget will reinitiate itself and change animation.

+

In this case you would use auto-recalculate-bounds to ask the widget to always recalculate the bounds, as in the top example.

+

If want to keep the scale consistent, but fit multiple animations in the container, you can use the animation-bounds attribute to define a bounds containing a list of animations, as in the bottom example.

+ +
+
+ + +
+
+ + + +
+

+                
+            
+
+
+ + + + + + +
+ +
+
+

If you want to display a sequence of animations without using js or on multiple tracks, you can use the animations attribute.

+ +

It accepts a string composed of groups surrounded by square brackets, like this: [...][...][...]

+ +

Each square bracket represents an animation to play, with some parameters. It contains a comma separated list with the following: +

    +
  1. track: the number of the track on which to play the animation
  2. +
  3. animation name: the name of the animation to play
  4. +
  5. loop: true, if this animation has to loop. False, otherwise
  6. +
  7. delay: the seconds to wait after the start of the previous animation, to play the animatino of this group (not available for the first animation on this track)
  8. +
  9. mixDuration: the mix duration between this animation and the previous (not available for the first animation on this track)
  10. +
+

+ +

Once you composed your animation, if you that is loops once it reaches the end, you can add the special group [loop, trackNumber], where: +

    +
  • loop: is the "loop" string to identify this special group
  • +
  • trackNumber: is the number of the track you want to be looped
  • +
+

+ +

+ The parameters of the first group of each track are passed to the `setAnimation` method, while the remaining groups on the track use `addAnimation`. +

+ +

+ You can use respectively use `setEmptyAnimation` or `addEmptyAnimation`, by using the string #EMPTY# as animation name. In this case the loop parameter is ignored. +

+ +

+ The default-mix attribute allow to the the default mix of the AnimationState. +

+ +

Have a look at the two examples below.

+
+ +
+ +
+ +
+

Spineboy here uses the following value for animations attribute.

+

+ +

+ + We use a single track for this animation. Let's analyze it: +
    +
  1. [loop, 0]: when the track 0 reaches the end, start from the beginning
  2. +
  3. [0, idle, true]: set the idle animation in loop
  4. +
  5. [0, run, true, 2, 0.25]: queue a cycle of the run animation, start it after 2 seconds from the beginning of the previous one, set a mix of 0.25 seconds from the previous one.
  6. +
  7. [0, run, false]: queue a cycle of run animation
  8. +
  9. [0, run, false]: queue a cycle of run animation
  10. +
  11. [0, run-to-idle, false, 0, 0.15]: queue a cycle of run-to-idle animation, with no delay, and a mix of 0.15 seconds
  12. +
  13. [0, idle, true]: queue the idle animation in loop
  14. +
  15. [0, jump, false, 0, 0.15]: queue a cycle of jump animation in loop, with no delay, and a mix of 0.15 seconds
  16. +
  17. [0, walk, false, 0, 0.05]: queue a cycle of walk animation in loop, with no delay, and a mix of 0.05 seconds
  18. +
  19. [0, death, false, 0, 0.05]: queue a cycle of death animation in loop, with no delay, and a mix of 0.05 seconds
  20. +
+
+ +
+ +
+ +
+

Celeste here uses the following value for animations attribute.

+

+ +

+ +

+ It uses two tracks. In track 0 we simply set the wings-and-feet animation.
+ In track 1 we loop over the entire animation, set an empty animation and queue an eyeblink animation with a 2 seconds delay. +

+ +

You can modify the textarea above and experiment with the values. For example, change the delay from 2 to 0.5, or add the swing animation to track 0 like this [0, swing, true, 5, .5] with a delay of 5 seconds and a mix of 0.5 seconds. Click the button below and Celeste will start to blink the eyes more frequently.

+ + +
+ + +
+ + + + +
+

+                
+            
+
+
+ + + + + + +