azerion / phaser-spine

A plugin for Phaser 2 that adds Spine support
MIT License
121 stars 58 forks source link

example of events onComplete, onEnd #55

Closed TinyDobbins closed 7 years ago

TinyDobbins commented 7 years ago

can you please add the example how to detect onComplete, onEnd event of animation?

AleBles commented 7 years ago

You ca now check the spineboy example for this: https://github.com/orange-games/phaser-spine/blob/master/example/spineboy.html

TinyDobbins commented 7 years ago

@AleBles let me know please how to get the current animation name? I do it via mySpine.state.tracks[0].animation.name but may be are there better way to get it?

AleBles commented 7 years ago

Not afaik, but I could write a simple getter like:

mySpine.getCurrentAnimationForTrack(0).name

But you'd still have a lot to type then :P

TinyDobbins commented 7 years ago

I thought about like that: mySpine.animations.current.name :) track is 0 always, right?

AleBles commented 7 years ago

Nah, that's a bad assumption (imho). You can specificly set animations on different track, there's nothing stopping you from using track 1 (or 99) allowing you to play different animations at the same time. The fact that you (and I :P ) don't use it doesn't mean there is a valid use-case.

To quote a guy from spine:

A "track" is a numbered placeholder for a track entry. A track entry stores information about an animation, such as which animation, if it should loop, what track entry to play when it is done, etc. Every frame, the animation for each track is applied one after another, lowest track number to highest. By applying multiple animations each frame, you can eg have a shoot animation that is played on top of idle, walk, run, swim, etc.

So I'd like to keep track support in. (I'd like all spine features to work as much as possible)

TinyDobbins commented 7 years ago

@AleBles Thanks for your reply! you are right.