The forum is kind of slow these days, so I figured out I could start explaining the code we are going to share from our project, Anarkade, an what you can do with it.
First post is going to be about our Tween library. I have already shared an stand alone version before, but this new version is much more easier to use.
Example:https://imgur.com/a/3X4T5fdAll these animations you can see in the example are done with out tween library.
How to use:- project
- game source
- library <- here
- include the tween library:
include "../library/motion_tween.inc";
- done! you can start using it.
Explanation:tween_to(int* property, int toValue, int effectType, int duration)The library works by modifying any int variable you pass to it as a pointer. You can use it with any local variable of your processes, like x, size or alpha.
Then you select what's the value you want it to transition to, lets say you want your size to go from 0 to 100, you should init your size variable in 0 and then call the function tween_to with toValue as 100.
After that you pass what transition effect to use, and how much frames to animation should take.
The values for effect type can be any of the following struct:
struct motion_effect
// Regular
int regularEaseIn = 1;
int regularEaseOut = 2;
int regularEaseInOut = 3;
// Bounce
int bounceEaseIn = 4;
int bounceEaseOut = 5;
int bounceEaseInOut = 6;
// Back
int backEaseIn = 7;
int backEaseOut = 8;
int backEaseInOut = 9;
// Strong
int strongEaseIn = 10;
int strongEaseOut = 11;
int strongEaseInOut = 12;
//Elastic
int elasticEaseIn = 13;
int elasticEaseOut = 14;
int elasticEaseInOut = 15;
end
To wait until the animation is finished, you can use the function
tweening()
while(tweening())
frame();
end
To wait just for one specific anim to finish, just use the function exists()
anim = tween_to(&size,100, motion_effect.regularEaseOut, 10);
while(exists(anim))
frame();
end
And that's all!! please let me know any question or bug you might find, it is a work in progress!