MODULE: Tween 1.5.1

Started by edmundito, Sun 14/06/2009 04:42:24

Previous topic - Next topic

edmundito

See the Tween 2 thread for the latest version!

---

The AGS Tween Module allows you to programmatically interpolate many of the ags properties (objects, characters, sounds, 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.

So for example I say:
Code: AGS
cEgo.TweenTransparency(1.0, 100);


Within one second, character Ego will interpolate from its current transparency to 100, thus fading it out.

Things you can tween so far include:
Position for Characters, GUIs, Objects, and Inventory
Position by Seconds or by Speed
Transparency for Characters, GUIs and Objects
Scale for Characters
Size for GUIs and Inventory
Viewports
Gamma
Shake Screen
Audio
Area Scaling
Images
Animation Speed
Z Order
Light Levels
Tint
Color
GUI element values


You can also ease the timing of the tween! This means that you can set it to accelerate and/or decelerate over time, which makes it a lot smoother. For example, if I'm moving a car from point a to b, I want it to look like it's decelerating when as of to simulate breaking, so I can do that with one function:

Code: AGS
// In 2 seconds, tween the car object position to where it's now + 150 in x, and "ease out" the tween.
oCar.TweenPosition(2.0, oCar.x + 150, oCar.y, eEaseOutTween);


You can also do all Tweens non-blocking, so you can do complex effects at once:

Code: AGS
float seconds = 1.0;
cEgo.TweenTransparency(seconds, 100, eEaseOutTween, eNoBlockTween); 
cEgo.TweenScaling(seconds, 5, eEaseOutTween, eNoBlockTween); 
cEgo.TweenPosition(seconds, 320, 240, eEaseOutTween); // blocking by default.


So, this comes in handy for GUI animations, credits, and maybe even action sequences. I'm hoping that this module will help everyone enhance their games a lot easier!

---

Module, and Source code (with Demo) (for AGS 2.72 and above!)
https://github.com/edmundito/ags-tween/releases/tag/v1.5.1

(Source and Demo project require AGS 3.3)

Mirror (In case you can't download it from the Google Code site)
http://www.losmunditos.com/downloads/ags-tween/

This module is distributed under the MIT License, which is pretty liberal to what you can do with this module. But feel free to give us credit for it! The help file provides who to provide credit if you wish to do so!

Changes in 1.5.1 (September 20, 2014):
- Fixed bad import statements for various *BySpeed tweens (viewport, GUI, GUI control, and character)
- Fixed Y miscalculation in GetDistance function (use for speed tweens)
- Fixed new strict audio check issue that would make module incompatible with AGS 3.1 and below.
- Fixed incorrect documentation

Major changes in 1.5 (2012):
- Support for AGS 3.2+ new-style audio!
- Ability to wait for running tweens to stop
- Ability to tween position by speed instead of time!
- Simplified GUI control Tweening
- Massive clean up under the hood
The Tween Module now supports AGS 3.6.0!

xenogia

Amazing work, I am definetly going to use this module in my upcoming release.

Dualnames

Great one Edmundito!!! Easy to use. Easy to master!! Thanks to Grundy for hosting too!!
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Snake

Edmund! This is amazing! I haven't tried it yet, only watched the demo, but this is awesome work. I'm definately going to use this :)

Thank you so much!
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

JD

Just watched the demo. That's really well done! Great module!

Vince Twelve

Awesome work here!  I use this same effect with GUIs all over Resonance.  I wish I had this module when I started so I wouldn't have had to script it all myself.  I would definitely consider using this in future games rather than port over my own messy code from Resonance.

Ghost

Shit yeah, this is really awesome stuff- I bet we will see this one used a lot in future games! Great, great work. And so simple to use!

edmundito

Thanks for the comments, guys! I'm glad you like it so far. Feel free to post any bugs or problems that come along the way. I will try to fix those or give tips on how to accomplish what you would like to do.

Vince, when I was working on this I was actually wondering how you did all the GUI animations for Resonance because it's one of the few AGS games I've seen that does some fancy stuff! Oh well... there's always chapter 2 and 3, right? :D I also noticed that some other game that I'm currently testing did GUI animations blocking, and I figured that with some AGS black magic I could come up with be a better (and much easier) way to do it.
The Tween Module now supports AGS 3.6.0!

Knox

--All that is necessary for evil to triumph is for good men to do nothing.

Monsieur OUXX

 

Dualnames

I managed to replicate all the mess i had on HHGTG, things that it took me a long time to script, but it was really easy to set with your module. Thanks man..

Is there a license btw?
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

edmundito

No license yet. I'd like for it to be free and pretty open to change. I would like though to know who' s using it at least! Is there a specific module license?
The Tween Module now supports AGS 3.6.0!

abstauber

I simply adapted SSH's license, since everyone's using his modules.
So it can't be that bad :)

TerranRich

This is an amazing module, netmonkey. In fact, this should be included as a built-in feature to AGS. I'm definitely using this module in my games. ;D
Status: Trying to come up with some ideas...

Snake

Edmund, would it be possible to implement scaling the GUI's background picture within the GUI when being sized? Right now it only resizes the border and the picture stays the same.

No big deal, just thought it would be neat :)
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

edmundito

Right now the teen size for GUI is based on GUI.setsize. I'm not sure if we can really set the scale of a GUI right now, unless chris is willing to add it... ;)
The Tween Module now supports AGS 3.6.0!

Dualnames

I'd beg for being able to Tween GUI Buttons (to be precise sliders).. ;)
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

tzachs

Sweet! :)
This is a really cool and useful model...
I have a suggestion for another tween, although I don't know if it can be implemented in AGS: The idea is to tween between two images (in the same size, for simplicity), to take the RGB value for each pixel in the first image and to interpolate to the RGB value for its equivalent pixel in the second image... I think it will provide for nice effects...
Anyways, really loved the model (and the demo).

NsMn

Hey, that's really useful! I tested it and it can always come in handy. Great work!

btw, will there be a TweenSetViewportX(); or something in a future version?

edmundito

Quote from: tzachs on Fri 26/06/2009 19:36:21
Sweet! :)
This is a really cool and useful model...
I have a suggestion for another tween, although I don't know if it can be implemented in AGS: The idea is to tween between two images (in the same size, for simplicity), to take the RGB value for each pixel in the first image and to interpolate to the RGB value for its equivalent pixel in the second image... I think it will provide for nice effects...
Anyways, really loved the model (and the demo).

if I get what you mean, it may be possible to do that:
Code: ags

oFromImage.SetPosition(0, 0);
oToImage.SetPosition(0, 0);

oToImage.Transparency = 100;

oFromImage.TweenTransparency(1.0, 100, eLinearTween, eNoBlockTween);
oToImage.TweenTransparency(1.0, 0);


Thanks for the suggestions so far! For sure I want to make all GUI widgets tweenable so I'll work on that next. And i'll also add the license! Let's just so say that it'll be the module gpl license most likely.
The Tween Module now supports AGS 3.6.0!

SMF spam blocked by CleanTalk