MODULE: Tween 1.5.1

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

Previous topic - Next topic

tzachs

Quote from: Edmundito on Sat 27/06/2009 21:01:45
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.

Yes, that's exactly what I wanted! I don't know how missed this...  ???
Thanks...  :)

TerranRich

Not even that complicated, Edmundito... have the "to" image behind the "from" image, both opaque and visible, and tween the "from" image's transparency out, leaving the "to" image to be revealed beneath it. Therefore, AGS handles it automatically. :)
Status: Trying to come up with some ideas...

tzachs

Quote from: TerranRich on Sun 28/06/2009 21:59:22
Not even that complicated, Edmundito... have the "to" image behind the "from" image, both opaque and visible, and tween the "from" image's transparency out, leaving the "to" image to be revealed beneath it. Therefore, AGS handles it automatically. :)

This solution might work in some of the cases, but it won't work if the "from" image has transparent parts, thus revealing parts of the "to" image too soon and diminishing from the effect... Edmundito's suggestion covers those scenarios as well...

TerranRich

Ohhh, right. In that case, the original code works better. :)
Status: Trying to come up with some ideas...

edmundito

Or something. I wrote that code blindly to tell you the truth! But I figured something like that would do the trick!  :=
The Tween Module now supports AGS 3.6.0!

edmundito

Well, I've looked at licenses and other libraries that inspired me to write this one, and I decided to go with MIT. Is that cool with AGS games? Essentially I'd like people to use it for both commercial and non-commercial purposes. A credit somewhere in the game or the ags game page is most welcome but not required. Let me know if this is a problem.
The Tween Module now supports AGS 3.6.0!

TerranRich

Making it usable with commercial games would be ideal. I'd give you prominent credit. :D
Status: Trying to come up with some ideas...

Dualnames

Quote from: Edmundito on Fri 10/07/2009 03:35:24
Well, I've looked at licenses and other libraries that inspired me to write this one, and I decided to go with MIT. Is that cool with AGS games? Essentially I'd like people to use it for both commercial and non-commercial purposes. A credit somewhere in the game or the ags game page is most welcome but not required. Let me know if this is a problem.

Whatever you wish, the way I have my license for HHGTG I'm giving credit to everybody whose module I'm using.
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

Ok, so I went a little crazy here, and I hope it's ok... I went over the ags documentation and found a bunch of new tweens to add to the module (some more useful than others)... So I implemented them all and created an interactive demo to show most of them (and the first ones as well)...

Module
Demo
Source for Demo

There are ~30 new tweens, among them you will find:
TweenPosition and TweenSize were added also for all of gui types...
TweenViewPort, TweenAnimationSpeed for character, TweenImage for object, TweenAreaScaling, TweenColor(for R,G and B respectively) for label, button and textbox, TweenLightLevel for region and more...

A few comments about some of the tweens:
* TweenMasterDigitalVolume will not always work as expected due to AGS bugs, you can see my report here (it's possible that TweenChannel/Sound/Speech volume will suffer from the same bugs, I didn't test it, however TweenMasterMusicVolume doesn't suffer from these bugs).
* TweenTintR/G/B for Region works well for one direction, but not so well to the other due to a weird relationship with the LightLevel for a region in AGS that I didn't fully understand.
* TweenImage for object will require you to pass a second 'dummy' object as a parameter, this is because I didn't find any way to create an object programmatically.
* Some of the tweens will require you to also give a "from" parameter (such as the tweens for volume), this is because I didn't find any functions to get values for those tweens, only to set (for instance, there is no GetMusicMasterVolume).
* There are some tweens that I wanted to create but gave up at the end, I wanted to create a tween for SetWalkSpeed but gave it up since I got an error message that said I can't set a walk speed for a character while he's already walking, and I wanted to create tweens for all of the parameters in the SetAmbientTint function but gave it up since there is no GetAmbientTint and without it the functions require too many parameters...

Edmundito, I just wanted to say that I found the design of the module was excellent and it allowed me to add new tweens in a fairly easy manner, and I will be very happy if you want to take the module extension to the beginning of the thread so everybody will be able to find it...

edmundito

Nice changes! I was thinking about doing that myself, but I wasn't really planning for adding that much!

And now here's an update:

New 1.0 version is up with the MIT license. Enjoy! I'm also hosting this on Google Code. Most likely version 1.1 official will come sometime soon incorporating tzachs' changes.
The Tween Module now supports AGS 3.6.0!

Ghost

You've got this Ghost's eternal thanks! Awesome stuff, I can't say in how many small ways this is useful- especially the non-blocking tweening of GUIs!

HammerBlade

  ;D  I was contemplating how to accomplish this effect...I had no idea the name for it was "tweening".  Thanks for this, you may have saved me weeks of research and work!

Vince Twelve

Man, can I just say again how much work this would have saved me if it had been made before I started Resonance two years ago? 

I'm using a whole bunch of similar tweens all over, especially non-blocking GUI location tweening.  I use Viewport tweening all around the place, too.  AGS never has control of the camera in my games.  I've used the same code for that in Nanobots, Puzzle Bots, and Resonance. And I actually just added the animation speed tweening to Resonance this week and was coming here to suggest animation speed tweens and viewport tweens for this module, but then saw that tzachs just added them both.  Well done Edmundo and tzachs! 

I predict much cooler and smoother effects in upcoming games thanks to this.

Helme

Thanks for this module!
It made many things so much easier to code!

NsMn

I have another suggestion: would it be possible to implement other ways of fading, like dissolve? That would be helpful if eg. you're having a 8-bit-game or something.

edmundito

Hey hey! After many months I've finally released an official version 1.1 with tzach's awesome changes! I call it the I-wish-there-was-an-AGS-award-category-for-modules-again edition.  :=

The first post has been updated with the latest version, but you can always get 1.0 and previous versions from: http://code.google.com/p/ags-tween/downloads/list
The Tween Module now supports AGS 3.6.0!

Dualnames

Hey, I'm using version 1.0, is there a way to disable tween effect? Turn it off that is, but with the following result. Let's say we have a tween position for a GUI, if i turn off the tween will it instantly place the GUI to the position? Same question regards transparency.
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

You mean to the end position? Nope, that's not possible at this time... I mean the closest thing is to have a:

startcutscene();
tweencode();
endcutscene();

...and pressing escape, but I'm guessing you want to have control over forcing it. I think it's a pretty good idea so I will add it to the list of things to do.
The Tween Module now supports AGS 3.6.0!

Dualnames

Code: ags

float ComputeTiming(int currentTime, int duration, TweenTiming timingType) {
	float timing = IntToFloat(currentTime) / IntToFloat(duration);
	

if (disabled) {
	if (timingType != eLinearTween) {
	  float timing2 = Maths.RaiseToPower(timing, 2.0);
	  
		if (timingType == eEaseInTween) {
		  timing = ((3.0 * timing2) - (timing2 * timing)) * 0.5;
		}
		else if (timingType == eEaseOutTween) {
		  timing = ((3.0 * timing) - (timing2 * timing)) * 0.5;
		}
		else if (timingType == eEaseInEaseOutTween) {
	        timing = (3.0 * timing2) - (2.0 * timing * timing2);
		}
}
}
if (!disabled) {
	timing=1.0;
	return timing;
}
}


I found out that this works.
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

Yep, that would do the trick... of course, every other tween would also stop, too...

Actually I did give it a bit of a thought and I might have a decent solution in the next version... so stay tuned :D
The Tween Module now supports AGS 3.6.0!

SMF spam blocked by CleanTalk