Latest Version is 2.2.0 - See the Tween 2.2.0 thread for more details!The AGS Tween Module allows you to programmatically interpolate many of the AGS properties (objects, characters, regions, viewport, audio, gui, gui controls, etc.) over time in amazing ways. The term tween comes from "inbetweening". It's typically used in Adobe Flash to indicate interpolation of an object from one keyframe to another.
Instead of depending on while loops everywhere in your code:
while (gIconbar.Y > -gIconbar.Height) {
gIconbar.Y = gIconbar.Y - 1;
Wait(1);
}You can do this:
gIconbar.TweenY(0.5, -gIconbar.Height, eEaseInBackTween);Notable games using the tween module include: A Golden Wake, Primordia, the Ben Jordan series, and Gemini Rue.
---
Tween 2.x is a huge upgrade from Tween 1.x. It is closer to the vision I had when I first started working on the first Tween module while still keeping the simplicity of the original.
Major changes include:
New Easing FunctionsThe new easing functions are based on common easing functions used by other tween modules. These include elastic, bouncing, backing out, etc.
You can see a demo of these at
http://easings.net.
Stop Individual TweensYou can now stop individual tweens:
cEgo.TweenPosition(2.0, 100, 100, eEaseLinearTween, eReverseRepeatTween);
// ... Later:
cEgo.StopTweenPosition();Tween by SPEEDYou can tween ANYTHING by speed instead of seconds as well. This allows you to move objects at a constant speed regardless of where they are.
Start DelayYou can delay the start of any tween allowing you to create interesting effects.
Convenient fade out and fade in tween functionsgIconbar.TweenFadeOut(0.5);Custom TweensFor the advanced users who like to have control, you can also create your own custom tweens that take advantage of the module's easing and timing functions. This also allows you to create tweens for drawing surfaces.
function TweenIndyMapLine(int fromX, int fromY, int toX, int toY) {
Tween.IncreaseGameSpeed();
Tween myTweenX;
Tween myTweenY;
myTweenX.Init(3.0, fromX, toX);
myTweenY.Init(3.0, fromY, toY);
int previousX = FloatToInt(myTweenX.FromValue);
int previousY = FloatToInt(myTweenY.FromValue);
int drawColor = Game.GetColorFromRGB(255, 0, 0);
while (myTweenX.IsPlaying() || myTweenY.IsPlaying()) {
myTweenX.Update();
myTweenY.Update();
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawingColor = drawColor;
surface.DrawLine(previousX, previousY, myTweenX.Value, myTweenY.Value, 3);
surface.Release();
previousX = myTweenX.Value;
previousY = myTweenY.Value;
Wait(1);
}
Tween.RestoreGameSpeed();
}No longer compatible with AGS 2.x!If you would like to use the tween module with an AGS 2 game, then get the
Tween 1.x module.
---
Download from:https://github.com/edmundito/ags-tween/releases/tag/v2.1.0Documentation:http://ags-tween.readthedocs.io/en/v2.1.0/Support Chat:https://discord.gg/vmuCyWXIssues and Feature Planning:https://github.com/edmundito/ags-tween/issuesSpecial Thanks to:Tzachs for expanding the original module to support most of the properties in AGS,
Grundislav and
Dualnames for promoting and creating very inspiring work with the original module,
jwalts37 who I met in person at GDC 2014 and told me how much he liked the module,
Vince Twelve for showing me some advanced code that was the inspiration for Tween 2's startDelay,
Calin Leafshade for giving me more insight into scripting best practices, and everyone in the forum for reporting problems and making games with this.