Today I finally cleaned up a library that I've been using since quite a while now and that I find very helpful to add animation.
sequence.lua.zip (2.5 KB)
It allows you to play a sequence of easings. It's so much easier to add more interesting or complex animations.
In our game I'm still using my own easing library (that I also used for quite some time) so I had to refactor a bit to use the playdate ones. Maybe that introduced some bugs. Let's hope not.
So has an example, this is how I animated out logo when you arrive on the main menu.
pick_anim_x = sequence.new():from(150):sleep(0.4):to(50, 0.3, "outCirc"):to(0, 0.5, "outExpo")
pick_anim_y = sequence.new():from(-240):sleep(0.4):to(0, 0.3, "inQuad"):to(-30, 0.2, "outBack"):to(0, 0.5, "outBounce")
pack_anim_x = sequence.new():from(150):sleep(0.2):to(50, 0.3, "outCirc"):to(0, 0.2, "outExpo"):start()
pack_anim_y = sequence.new():from(-240):sleep(0.2):to(0, 0.3, "inQuad"):to(-30, 0.2, "outBack"):to(0, 0.5, "outBounce")
pup_anim_x = sequence.new()
pup_anim_y = sequence.new():from(-240):to(0, 0.5, "outBack")
And this is the result
SequenceExample.zip (27.9 KB)
In your code you just have to call the update function
sequence.update()
To trigger an animation just call
pick_anim_x:start()
And to get the value
pick_anim_x:get()
That's it
Update September 2022
it is on GitHub now GitHub - NicMagnier/PlaydateSequence: Create animations with simple sequences of easing functions in your playdate game