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!

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!

edmundito

Guess what, boys and girls? Tween is almost a year old and to celebrate I've updated it to 1.2! Here's the changes:

- New: You can now change the defaults for TweenTiming and TweenStyle.
 (GUIs have their own defaults, and NOTE that as of this version GUIs are blocking by default.)
- New: You can now set how tweens stop, whether they pause, finish, or reset (thanks to Dualnames for the inspiration!)
- New: WaitSeconds(seconds), very handy for timing things instead of guessing number of loops with regular Wait()
- General code cleanup, removed some redundancies
- Better code documentation

For stopping Tweens, you can now do things like the following...

Code: ags


// All tweens are now blocking for consistency, but you can change it at the top of the module file
gIconbar.TweenTransparency(2.0, 100, eLinearTween, eNoBlockTween); // Fade out in 2 seconds

WaitSeconds(1.0); // new handy-dandy function

gIconbar.StopAllTweens(eResetTween); // Puts it back to its original transparency
//gIconbar.StopAllTweens(eFinishTween); // Or finish it immediately!
//gIconbar.StopAllTweens(); // Or leave it as is.




There isn't tween support for the newer features of AGS 3.2 yet. I know there's some new features that could probably be tweenable but I haven't had a chance to look at it. Let me know if you'd like to see any of these features available in 1.3.

The Tween Module now supports AGS 3.6.0!

Dualnames

Great job Edmundo!! Thanks for implementing this! :D
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)

Codex


ddq

I honestly don't have any idea what I would do without this module. You deserve massive props.

edmundito

Hey guys, quick update: I realized that I may have introduced a little bug in the system with the new stop tween stuff, so I went ahead and did a minor correction to it and still labeled it 1.2 (instead of 1.21, but only this time around)...

So, please download it again if you did it this weekend! Sorry about the trouble...
The Tween Module now supports AGS 3.6.0!

Sslaxx

Quote from: Edmundito on Sat 05/06/2010 19:26:19
There isn't tween support for the newer features of AGS 3.2 yet. I know there's some new features that could probably be tweenable but I haven't had a chance to look at it. Let me know if you'd like to see any of these features available in 1.3.
3.2's changed music system also results in an error message when I imported Tween 1.2 into an AGS 3.2 project.

Quote from: AGS 3.2.0 Final 5Tween.asc(282): Error (line 282): Undefined token 'SetMusicMasterVolume'
Quote from: Tween.asc line 282SetMusicMasterVolume(Lerp(this.fromX, this.toX, amount));

Doesn't seem hard to fix it up, just onerous (if you don't want to change the relevant backwards compatibility option).
Stuart "Sslaxx" Moore.

edmundito

#46
Duly noted, so here's version 1.21, which is compatible with AGS 3.2, including the demo game. :)

Most audio support gets turned off in 3.2 unless you change the setting Enforce new-style audio scripting to False in the General Settings.

Looks like overall support for audio tweening needs some more care, so the new system support will come in a later version of the module.
The Tween Module now supports AGS 3.6.0!

edmundito

New revision to celebrate the return of the forums! woohoo! This one is not too exciting, I've basically gone back and made sure that our current code is compatible with AGS 2.72 and AGS 3.0 because it looks like we lost some of that when we released version 1.1.

Feel free to leave problems/suggestions here or report stuff to our google code site at:
http://code.google.com/p/ags-tween/issues/list

I've also started a list of games using the tween module:
http://code.google.com/p/ags-tween/wiki/GamesUsingTheTweenModule

Now that the forums are back I will update with with the ones I've been credited with. If you have any games that are released that used the module, feel free to PM me and I'll add it!
The Tween Module now supports AGS 3.6.0!

Pinback


RedTalon

A truly wonderful mod. Helps with animations dealing with teleportation and wheeled robots.  :D
Website:
www.redtalongames.com
Twitter:
www.twitter.com/redtalongames

tzachs

Quote from: RedTalon on Sun 12/09/2010 21:59:34
A truly wonderful mod. Helps with animations dealing with teleportation and wheeled robots.  :D

Indeed  :)
Just in case it wasn't clear before, this is my favorite module in all times!

Iliya

Great job Edmundito! I just found the tween module. I have great ideas for improving my games. Especially the objects moving!

Thank you very much!

ThreeOhFour

I finally downloaded this and tried using it today!

Two things I'd like to see but can't seem to find in here - could tweening support for individual variables (ints and floats) be added? And also for drawingsurface functions, such as DrawImage?

Ta!  :-*

edmundito

Ben, can you give me an example of how you would like to tween a variable? Would it be something along the lines of:

Code: ags

int amount = 0;
TweenInt(amount, 100, eEaseOut);


?

Drawing surfaces is something I could add, too. It could take some time... mostly testing it and making sure that it works. Let me know if you want to be my guinea pig for that. :P
The Tween Module now supports AGS 3.6.0!

ThreeOhFour

Yes, tweening a variable was mostly to make use of the easing in styles, and also for plugging in tweened variables so that we can try tweening things that are not yet supported ourselves  :=

Always willing to be a guinea pig (although do keep in mind I'm a pretty basic coder in terms of skill level (pretty extreme coder in terms of ambition sometimes  :D))

edmundito

Hmm, actually I'm not sure if we can tween variables in AGS, because with the scripting language limitations I cannot get a reference of the same variable I think. I'd have to look into it (don't have access to a Windows PC right now ¬¬) but can one of the more technical people get back to me on whether AGS  supports pointers for int and float?

I could maybe add tween to the old global ints as such, but it would be messy:

Code: ags

boolean fooIsTweening;

function TweenFoo() {
    fooIsTweening = true;
    TweenGlobalInt(5, 100);
    fooIsTweening = false;
}

function repeatedly_execute_always() {
    if (fooIsTweening) {
       foo.x = GetGlobalInt(5);
    }
}
The Tween Module now supports AGS 3.6.0!

Icey

Just wondering would it ever be possible to tween music? Like cross fading but with more control.

WHAM

My Gods! It is beautiful! I am so using this in the future!
Wrongthinker and anticitizen one. Pending removal to memory hole. | WHAMGAMES proudly presents: The Night Falls, a community roleplaying game

David Ostman

I'm using object.TweenPosition, and when I invoke PauseGame() or pause the game when a GUI is visible, the tween animation continues to play.

So I have the player freezing as I bring up the inventory, but all the objects in the background keeps animating, which looks really weird.

Is this regular behaviour, or have I screwed something up?

I'm on 3.2.1 and this is the code snippet I use in room_AfterFadeIn():

Code: ags
oBGShip1.TweenPosition(9.0, 509, oBGShip1.Y, eLinearTween, eRepeatTween);

tzachs

AGS scripts has "repeatedly_execute_always" and "repeatedly_execute" functions.
Whatever is in "repeatedly_execute_always" will happen even when the game is paused, as opposed to "repeatedly_execute" that will only happen when the game is not paused.

So you have two options: if you want the tweens to pause then just go to the tween script file and replace "repeatedly_execute_always" with "repeatedly_execute".
If you want your other animations to not pause, then you have to switch all your animations to "repeatedly_execute_always" instead of "repeatedly_execute".

David Ostman

I tried that, but changing repeatedly_execute_always to repeatedly_execute in tween.asc didn't make any difference. The little ships in the background still animate when the game is paused. Been trying to figure out exactly what is going on here, but so far I'm drawing a blank.

edmundito

It's been a couple of years, but it's finally time for Tween 1.5! (informally titled Game Developers Conference 2012 Edition!)  8)

The biggest feature is that New-style AudioChannel from 3.2 is finally supported. I've also added some really cool new Tweens for positioning objects by constant speed instead of time. There was a lot of cleanup and improvements that were done to the code as well, making it easier to maintain for future versions (and this is why it went from 1.2 to 1.5...).

This is an RC1 (Release Candidate 1) because I haven't properly tested the thing yet. If you use it and find any issues, please reply to this thread and let me know and I'll start making some fixes!
The Tween Module now supports AGS 3.6.0!

Ghost

Sweet- I think I've use your module in almost every game. I'll give this a spin!


Snarky

Excellent!

I get an error on line 197 that token "gui" is undefined.

I was trying to test the repeat modes, because I seem to remember that it doesn't support a way to have something tween back and forth between two values indefinitely (so you could have a ball bounce up and down, for example), even though that's exactly what I would expect the ReverseRepeat mode to do. Anyway, that would be my feature request.

Calin Leafshade

Quote from: Snarky on Tue 06/03/2012 12:08:49
I get an error on line 197 that token "gui" is undefined.

This is almost always because you have no GUIs in your game.

Grim

That's wonderful! As a devoted Tween user I feel I really want to replace the old one I've been using in my game with this new 1.5 version and take it for a spin, I'm just a little worried it might mess things up with the old version already being used in almost every room in the game. Will old commands still work like they do or will I have to go back and rewrite everything?

But I've dreamt of using Tween for sound manipulation for so long.... This, truly, is the greatest module ever made for AGS! ;)

edmundito

Thanks for the testing so far guys!

@Snarky:
Can you confirm what CalinLeafshade said? And also can you paste some of the tween code you were trying to write tosee why your reverse repeat mode doesn't work?

@Grim:
What is the old version? Tween 1.5 remains mostly backwards compatible, you just have to tweak a few variables at the top of the headter script file to turn on old features. In any case, look at the previous version of tween that you are using and if all else fails you can replace it with the old version from http://code.google.com/p/ags-tween/downloads/list. If you need any help feel free to send me a forum message.
The Tween Module now supports AGS 3.6.0!

edmundito

"I get an error on line 197 that token "gui" is undefined."

- Calin is correct. Looks like you can't run the Tween module at the moment if you don't have any GUIs defined.

Does anyone know if there is a way to solve this? I tried doing something sneaky such as:

Code: ags

#ifdef gui
// Bunch of gui tweening code
#endif


But looks like that doesn't really do what I expect. Does anyone have a better solution?
The Tween Module now supports AGS 3.6.0!

Dualnames

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)

Snarky

Sorry for the delayed response. I didn't have access to my PC for almost a week, and it's a pain to run it on my Mac.

Yeah, I just started writing from a blank game, so there weren't any GUIs. Bad form of AGS to not even declare it as a null variable if there aren't any, and I don't see how you can work around it. (No Dualnames, you can't just check GuiCount, because even if you make sure it doesn't run, the code still needs to be there, and it's either valid or invalid depending on whether the variable has been defined.) Maybe just document it and add a simple "// Object gui = null;" line to the top (and appropriate tests throughout) which users can uncomment if they need to use it in a no-GUI game.

As for the ReverseRepeat, I don't remember exactly what my problem was. I can see from the examples that it wasn't any of the basic functionality, like I thought. It might have been about knowing whether it's currently tweening forward or in reverse, or about resuming a paused tween. (Say you wanted all tweens to reverse whenever you pressed a button, for example.)

edmundito

Thanks for the info Snarky!

Yeah this gui seems like a semi-serious issue. Best thing to do is to as a work around is to create a gui and not just make it invisible and that should solve the problem.
The Tween Module now supports AGS 3.6.0!

Calin Leafshade

Is a reference to the gui array necessary?

Couldn't you just have an array of pointers to reference the guis that are passed to the module?

monkey0506

You can always maintain your own array internally:

Code: ags
// Script.asc
GUI *tween_guis[];

function game_start()
{
  if (!Game.GUICount) tween_guis = null;
  else tween_guis = new GUI[Game.GUICount];
  int i = 0;
  while (i < Game.GUICount)
  {
    tween_guis[i] = gui[i];
  }
}


And then just replace "gui" with "tween_guis" in the rest of the module. Presumably you're not actually using the array if there's no GUIs, but just simply referencing the array (which is completely undefined if there are no GUIs)...otherwise you'd also need to add a safety catch in the functions that use it.

Snarky

I'm pretty sure that code is going to fail to compile in a game with no GUIs because of the "tween_guis[i] = gui[i];" line. That's why I think the way AGS currently does it is broken.

Edited because those aren't italic tags...

Eric

This is the first module I've ever downloaded and used. The instructions were nice and clear, and it seems to function well. Thank you!

I have one question, though. I'm using this to fade a GUI in and out, and during the fade, the buttons are greyed out. Is this normal, preventing access to the functions of the GUI before it's fully opaque? Or have I screwed something up? It's a fine situation in every aspect except I'd prefer them not to be greyed out, aesthetically.

monkey0506

Snarky- You're right...ugh...I don't know what I was thinking why I thought that wasn't prey to the same problem as it's a compile-time error not run-time. :-\

I would actually say that AGS not defining the array is a bug. The preferred method should be for the array pointer to exist, but it just be null (like a dynamic array). Otherwise, as there's no macro for this, there's no way of getting around this compile-time error short of referencing the GUIs directly by their name.

Snarky

monkey: Yes, that's what I meant. It's an AGS bug, and the appropriate thing would be to define gui as null (or a 0-length array) if there are no GUIs.

Eric, this is due to a setting in your AGS game project. Go to the general game settings and look for something like "grey out GUIs when disabled" and set it to false.

Eric

Quote from: Snarky on Thu 15/03/2012 19:34:15Eric, this is due to a setting in your AGS game project. Go to the general game settings and look for something like "grey out GUIs when disabled" and set it to false.

Thanks! I knew the fault lay with me somewhere, and not the module!

edmundito

Cool, I'm glad you guys are talking about ideas. There's some interested solutions here to the GUI problem.

What I did in 1.5 is minimize the number of references in the module internals. If you're nerdy enough, you can check the diff:
http://code.google.com/p/ags-tween/source/diff?spec=svn35&r=35&format=side&path=/trunk/Tween/Tween.ash
(Scroll all the way to the bottom)

The only one I had left is GUIControl because this is a newer structure that did not have an internal array created for it AFAIK. However I guess I could revert back the gui to use a reference GUI* pointer as well, since there's only 3 or so GUI Tweens to maintain anyway.
The Tween Module now supports AGS 3.6.0!

Sughly

I'd just like to let you know Edmundito that I've finally got a chance to play around with this and... I would like to marry you. To say this is saving me time/ giving me so much more creativity with my game is an understatement. *bows down before you*

Grim

I have a question that's been bothering me for a while (I think I saw it explained once, but can't seem to find it again). In my game I often use objects that are set to tween transparency in reverse-repeat (useful for shadows overlaying the whole room). So I've got something like this in room_load: object[1].TweenTransparency(2.0, 50, eLinear,eReverseRepeatTween), yeah? But as player re-enters the room that object's transparency won't be tweened from 0, as it was initially, but from whatever value it was at the time of leaving the room. I don't think setting object's transparency at room load just before tween command will make any difference- I believe it might get ignored unless I reset the tween. How do I do that?...

selmiak

I'm struggeling with the audio tweens.
I'm using AGS 3.2.1
When I'm setting enforce new style audio scripting to true in general setting, which I suppose is the mentioned strict audio settings, TweenVolume is not compiling. If strict audio settings is something different this might be solved already if someone could explain what strict audio setting is.
When I'm setting enforce new style audio scripting to false I can use TweenChannelVolume, but when I tween/mix a channel in, and tween it to volume 100 it is still stuck at something like 70 or 80. There is no VolumeReduction While Speech is playing active, and the strange thing is, to check on this I put in a GUI where 3 buttons check every channel volume with channel.Volume but the value only stays on values I set at the start of the room and doesn't even change with tweening the value, though the volume actually goes up, but not all the way to 100.

tzachs

Well, tweening for the new audio system was never developed (as far as I know).
As for the old audio, yeah, there are some known issues with the audio tweens.

Unfortunately the audio system in AGS (at least the old one, not sure about the new one) is a bit shaky and buggy...
I've mentioned it back then in this thread, and also reported the issues I've encountered here.

Basically if you play too much with the audio it might not work as expected...
Sorry I can't help you further.   :(



TheBitPriest

I found a small bug in the module.  Others may have seen this problem too.

float GetDistance(int fromX, int fromY, int toX, int toY) {
  return Maths.Sqrt(
    Maths.RaiseToPower(IntToFloat(toX - fromX), 2.0) +
    Maths.RaiseToPower(IntToFloat(toY - fromX), 2.0) // *** this should be fromY
  );
}


edmundito

Quote from: TheBitPriest on Thu 29/08/2013 03:07:00
I found a small bug in the module.  Others may have seen this problem too.

float GetDistance(int fromX, int fromY, int toX, int toY) {
  return Maths.Sqrt(
    Maths.RaiseToPower(IntToFloat(toX - fromX), 2.0) +
    Maths.RaiseToPower(IntToFloat(toY - fromX), 2.0) // *** this should be fromY
  );
}



Nice finding! I even added it to the bug tracker: https://code.google.com/p/ags-tween/issues/detail?id=8
I got someone else contact me over private messaging with a different issue, so I will find some time to fix it and release a new versions.
The Tween Module now supports AGS 3.6.0!

GlaDOSik

This Tween module is very useful. But is it possible to use tweens (for ex. on GUI) elsewhere than in room script? Like in my function in my own script and then call that function from room? I'm writing custom GUI and I don't want to copy GUI function in every single room.

Dualnames

Sure of course it's doable provided the script order of the modules is proper.
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)

Ghost

Quote from: Dualnames on Wed 25/12/2013 01:55:36
Sure of course it's doable provided the script order of the modules is proper.

To elaborate: Each script can use functions from any other scipt ABOVE it in the project tree- the order of the scripts is important and you can move them around in the editor by right-clicking and selecting move up/down. If you want to access functions from a script on a regular basis, just move it all the way to the top.

GlaDOSik

So that's why it doesn't work. I need to move Tween script up in project tree. Thanks Ghost for clarification.

Monsieur OUXX

Hi!

Is it possible to pause some tweens?
I've seen StopAllTweens(ePauseTween) (I suppose using ePauseTween pauses them) but I can't seem to find the reverse function to unpause everything.
 

edmundito

Quote from: selmiak on Mon 03/12/2012 20:51:58
I'm struggeling with the audio tweens.
I'm using AGS 3.2.1
When I'm setting enforce new style audio scripting to true in general setting, which I suppose is the mentioned strict audio settings, TweenVolume is not compiling. If strict audio settings is something different this might be solved already if someone could explain what strict audio setting is.
When I'm setting enforce new style audio scripting to false I can use TweenChannelVolume, but when I tween/mix a channel in, and tween it to volume 100 it is still stuck at something like 70 or 80. There is no VolumeReduction While Speech is playing active, and the strange thing is, to check on this I put in a GUI where 3 buttons check every channel volume with channel.Volume but the value only stays on values I set at the start of the room and doesn't even change with tweening the value, though the volume actually goes up, but not all the way to 100.

Sorry I released the last module and disappeared from the forum, but I'm trying to fix issues about it. Did you ever get this resolved? We did add the new audio support in 1.5 but let me know if you found any bugs.
The Tween Module now supports AGS 3.6.0!

Baron

I'm updating from a previous version, since I've updated to AGS 3.3 in the last year.  But when I download the module, I'm not seeing the .scm file I need to install/import the module.  Is there a new method to do this?

edmundito

Quote from: Baron on Fri 02/01/2015 18:11:08
I'm updating from a previous version, since I've updated to AGS 3.3 in the last year.  But when I download the module, I'm not seeing the .scm file I need to install/import the module.  Is there a new method to do this?

Very strange. I just downloaded the module from github and my mirror and both contain the .scm file. Did you download the ags-tween-1.5.1.zip file or the source code?
The Tween Module now supports AGS 3.6.0!

Baron

Ah....  I guess I had the demo game by mistake.  Thanks!

SMF spam blocked by CleanTalk