#SpineTutorial
Explore tagged Tumblr posts
learn-blesshaygaming · 8 years ago
Text
Play Spine Animation Tracks Exactly Once in GameMaker:Studio
Should work in GameMaker:Studio EA 1.99.525 (or newer). Should work in GameMaker:Studio 2 (all versions).
This tutorial is written for GameMaker:Studio but everything is applicable to GameMaker:Studio 2.
I used Spine version 3.4.02 for this tutorial. Always use the recommended version of Spine for your version of GameMaker:Studio.
The Problem
While GameMaker:Studio does have an Animation end event, this event only reacts on the main animation track (track 0), and not on all the other tracks. However, using the at-the-time-of-writing new Animation event event, you can now easily make sure that specific animations on any track only play once.
What to Do in Spine
youtube
As the video explains:
You first add the event to your hierarchy.
You then key the event at the last frame of the animations you want to stop after playing once (or wherever you want the animation to stop).
These animations will typically be secondary animations, and rarely the animations you place on track 0, as you can simply use the Animation end event for these, as explained before.
After this you of course export your character and loads it into GameMaker:Studio as a skeletal sprite.
What to Do in GameMaker:Studio
As there has not yet been written a manual entry on the subject of the Animation event event at the time of writing, you will have to use Nocturne's forum post on the topic for reference. Nocturne flesh out multiple other Spine-related updates in this post.
When the sprite is added and attached to an object, we now add the Animation event event to the object as well. You find the event under the Other category. You then add a code block to the event.
The event is triggered by Spine events and automatically generates a ds_map. This ds_map is accessed through the variable event_data local to the event. The ds_map contains multiple keys, but for our purpose we only need two: The "name" key, to check if the current event is the "stop" event, and the "track" key, to check which animation track the animation is running on.
Let's begin writing the code. First we test for the correct event:
if event_data[? "name"] == "stop" { }
Note that I use the accessor "?" to easily look inside the ds_map. After that we simply turn off the animation track in question by using skeleton_animation_clear();:
if event_data[? "name"] == "stop" { skeleton_animation_clear(event_data[? "track"]; }
..and Voilá!
Now your animation will stop after playing exactly once! Yes, it is really that easy. Hope you enjoyed!
Regards, Simon
1 note · View note
learn-blesshaygaming · 9 years ago
Video
youtube
Animating the "Software Bug" enemy for Omni [GameMaker:Studio + Photoshop + Spine]
4 notes · View notes
learn-blesshaygaming · 9 years ago
Video
youtube
Spine Tips for GameMaker: Studio - Reuse Meshes in Multiple (Differently Scaled) Attachments
2 notes · View notes
learn-blesshaygaming · 9 years ago
Video
youtube
Spine Tips for GameMaker: Studio - Reuse Meshes in Multiple Attachments
1 note · View note
learn-blesshaygaming · 9 years ago
Video
youtube
Spine tips for GameMaker: Studio - Animating Pixel Art
1 note · View note