• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Asset - Scripts AESnips - A powerful and easy to use sprite playback system [free]

angelwire

Member
angelEngine_snips_wide.png
AESnips is a system that allows objects to effortlessly handle simple or complex sprite animation playback for you.

Marketplace Link: https://marketplace.yoyogames.com/assets/9275/aesnips-animation-system

Summary:
Create "Snips" and simply tell an object to play the Snip animation and the system will handle everything for you.
No more worrying about sprite_index, image_index or writing complex code in the Animation End Event

angelEngine_snips_feature_list_small.png

For use in GMS 2.3

Documentation is available here: https://docs.google.com/document/d/1JSGG1mfid8lOiSictlqFUEiaxrTep1TUyvLne1Z2Yr0

Snips are powerful
Transitions between Snips make animations much more fluid. Any time you play a Snip you have the option to have the system try to find a Transition to bridge the gap between the Snip that is currently playing and the Snip you want to play. The system also automatically handles Snips that finish playing based on their end type. Snips can play once and stop, they can continually repeat, they can pingpong, and they can even call functions when done playing.
You can assign a function to be executed for each frame in a Snip - which is super useful for firing bullets or throwing objects.

Snips are dynamic
Each sprite frame can have its own speed. Split second delays can be added into animations without copy/pasting sprite frames or writing extra code.
Loops can be added to Snip animations to repeat certain frames. No more copy/pasting sprite frames to make your animations longer. Snip properties, frame speeds, and Loop repetition can be changed in-game, which means your animations can dynamically react to events in the game.

Snips are easy
Add one line to the animated objects’ Create Event, and Step Event it is ready to play Snip animations.
Create Snips with one line of code, play Snips with one line of code. Transitions and Loops can also be created with a single line of code and then you can completely forget about writing any more logic to handle them.
If you want more control over the Snips there are a lot of helpful “arbiter” functions that give you control without requiring you to memorize all the variable names.
Check the source code for the demo and to see just how easy it is to use.

Snips are growing
AESnips is still growing and I would love to be able to add more features to fit the needs of GameMaker developers who have interest in the system. If you’re making a game that relies heavily on sprite animations I would love to hear from you on what more you want from a system like this.

In this GIF the blue cowboy is playing one single Snip but using a Loop to twirl the gun. That Snip also has some slower frames to create a subtle delay before shooting the gun. There is a bullet_fire script attached to the gun firing frame. The cowboy can also skip the firing Loops to pull out the gun and then holster it without firing.

The red cowboy is made up of four Snips: "idle", "draw", "shoot", "holster". When the player presses space, the "shoot" Snip is played. After setting up the Snips and Transitions, only one line of code is needed in the Space Pressed event to play all 4 Snips in the perfect order, and fire the bullet! The "draw" Snip is the Transition between the "idle" and "shoot" Snip. The "idle" Snip is set as the successor to the "fire" Snip. And the "holster" Snip is set as the Transition between the "fire" and "idle" Snip.

Quick how-to-use:
Any object that uses Snips MUST call a function in the Create Event and Step Event. The functions are named appropriately:
  • snip_create_event()​
  • snip_step_event()​
You can create Snips, Transitions, and Loops anywhere in your code. Loops and Transitions are created using the "new" keyword. Snips can be created with "new" or with snip_create_ext(...).
You can make changes to a Snip's frames' speed or assign a script to each frame with snip_set_frame_speed(...) and snip_set_frame_script(...)
When you want your object to play a Snip use snip_play(Snip, transition?). Use snip_play_next(Snip, transition?) to queue up a Snip to play after the current Snip is done playing.
You can pause individual objects or all Snips by having the object call snip_pause()/snip_resume() and snip_global_pause()/snip_global_resume()

And that's a quick tutorial, I encourage you to check out the documentation and demo source code.
Documentation: https://docs.google.com/document/d/1JSGG1mfid8lOiSictlqFUEiaxrTep1TUyvLne1Z2Yr0


Marketplace Link: https://marketplace.yoyogames.com/assets/9275/aesnips-animation-system
GitHub repository including demo project and source code: https://github.com/angelwire/AESnips

I'm very open to feedback. This is a project that is still growing and I'd love to hear suggestions!

 
Last edited:

Joostar

Member
Damn I'm pretty new and learning and I feel like I'm gonna be so lost again once 2.3 comes out. So many cool new features. Gonna save this for later!
 

angelwire

Member
Damn I'm pretty new and learning and I feel like I'm gonna be so lost again once 2.3 comes out. So many cool new features. Gonna save this for later!
The GML updates in 2.3 are great. I started developing this project with the current stable release but I took a chance and started using 2.3 and working with it was so much better. I had to spend a couple hours studying the manual and watching tutorials, but it was definitely worth it.

New update v.02:
  • Added snip_draw_debug(x,y). This script will draw what you see in the GIFs of the main post
  • Fixed an error with Loops
 

❤️×1

Member
Honestly, it sounded kinda overkill but, once I actually tried it, AESnips is revealing another big gap in GMS2 feature set.
Also, ping pong and reverse animation are already in beta on github, only a few days after I asked @angelwire to add them. Awesome lib and awesome support \o/
 

angelwire

Member
0.1.3 update:
-Removed the need to use the Animation End Event
-Added pingpong playback via the new end_type enum
-Added the ability to play Snips in reverse
-Added the ability to clone Loops and Transitions from one Snip to another
-Added more playback control functions like snip_cancel_play_next(), snip_play_reqest()
-Fixed some bugs with the debug visual and Loops
-Check the AESnipsChangelog in the sample project for more info

Give it a try on the marketplace
Or check it out on GitHub

Thanks to @❤️×1 for the pingpong playback and reverse Snip suggestions!
 
Top