Tween 2.3.0 with AGS 3.6.0 support!

Started by edmundito, Tue 04/04/2023 01:35:15

Previous topic - Next topic

edmundito

About

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 the computer animation term inbetweening.



Don't depend on using while loops everywhere in your code to move something:

Code: ags
while (gIconbar.Y > -gIconbar.Height) {
  gIconbar.Y = gIconbar.Y - 1;
  Wait(1);
}

With the Tween module, can do graceful things like this:

Code: ags
gIconbar.TweenY(0.5, -gIconbar.Height, eEaseInBackTween);

Notable games using the tween module include Guard Duty, Lamplight City, Unavowed, Future Flashback, and Rosewater.

What are you waiting for? Start using the Tween module today!

---
What's new in 2.3.0?

TL;DR: This is a great new release that supports the new features in AGS 3.6.0, adds support for Point object tweens, and the long overdue support for Overlay X and Y. This module is compatible with AGS 3.5 or above.


Added Overlay TweenX, TweenY, TweenPosition
3.5.0: Added Point TweenX, TweenY, TweenPosition
3.6.0: Added Character TweenAnimationVolume
3.6.0: Character.TweenScaling is no longer limited by a range of 5-200. Now supports 1-32767
3.6.0: Added GUIControl TweenTransparency
3.6.0: Added Object TweenScaling
3.6.0: Added Overlay Width, Height, Size, and Transparency
Internal: Updated how managed tweens are created to support Point and Overlay tweens
Added function documentation where extra properties such as ManualScaling, Visible are also updated

---

Download from:
https://github.com/edmundito/ags-tween/releases/tag/v2.3.0

Documentation:
https://edmundito.gitbook.io/ags-tween/

Financial Support:
Happy to take tips or donations through my Ko-fi site: https://ko-fi.com/edmundito

Chat in the AGS Discord server:
https://discord.gg/vmuCyWX

Issues and feature planning:
https://github.com/edmundito/ags-tween/issues
The Tween Module now supports AGS 3.6.0!

eri0o

#1
Tweening Overlays is a god send for my random things! Thank you for this! I can probably now refactor a good portion of my old manamatch with this! (that code was before there was unlimited overlays too, so it was all using a hackedup software renderer made in script)

RootBound

#2

EDIT: SOLVED - I didn't realize there was an issues page, it was this one: https://github.com/edmundito/ags-tween/issues/2
---------------------------------



Hi @edmundito,

Running AGS 3.6.0, I get the following error:

QuoteTween.asc(751): Error (line 751): undefined symbol 'gui'

This is the code in question (error caused by final line):

Code: ags
function _TweenObject::Step(float amount) {
  switch (this.Type) {
    // GUI step
    case _eTweenGUIPosition:
      if (this.FromValue == this.ToValue) {
        _value = gui[this.RefID].X;
      }


Any idea what the problem is?

Thanks
J. They/them. Here are my most recent games:

RootBound

#3
OK, new problem. Can't figure out what I'm doing wrong in my scripting. Goal is to be able to pseudo change speed of tweens (including stopping and resuming) by doing the following:

1. getting the current fraction of tween's duration remaining through customtween.GetTweenProgress() and the current value through customtween.value.

2. stop the tween

3. start a new tween with the value and duration modified based on what was previously elapsed.

This is, however, not working. I have a label displaying the value of customtween.GetTweenProgress(which, if I understand correctly, is supposed to return a float value between 0 and 1), but instead the returned value almost instantaneously climbs to a 10-digit whole integer, and if the tween is paused and unpaused value returns to 0 (integer, not float) and stays there.

Any help would be greatly appreciated.

Here's my code:

Code: ags

Global variables: 
-----------------
int Speed = 0
int SpeedChange = 0
float TweenFraction
int CurrentTweenValue


Global script:
--------------

repeatedly_execute_always() {
   Label2.Text = String.Format("Scaling: %d", CurrentTweenValue);
   Label3.Text = String.Format("Progress: %d", TweenFraction);
}

function btnSpeedUp_OnClick(GUIControl *control, MouseButton button) {
  if (Speed < 3){
    Speed ++;
    SpeedChange = 1;
  }
}

function btnSpeedDown_OnClick(GUIControl *control, MouseButton button) {
  if (Speed > 0){
    Speed --;
    SpeedChange = 1;
  }
}


room script:
-----------

Tween IncreaseScaling;
float Duration;

function room_AfterFadeIn() {
  SetTimer(1,GetGameSpeed()/40);
}

function repeatedly_execute_always() {
  CurrentTweenValue = IncreaseScaling.Value;
  TweenFraction = IncreaseScaling.GetProgress();
  
  if (IsTimerExpired(1))  {
    SetTimer(1, GetGameSpeed()/40);
    if (IncreaseScaling.IsPlaying())  {
      IncreaseScaling.Update();
    }
    cTree.Scaling = IncreaseScaling.Value;
  }
  if (Speed == 0) {
     cTree.StopMoving();
     IncreaseScaling.Stop(ePauseTween);
  }
  if (Speed == 1){
     Duration = 3.0;
  }
  if(Speed == 2){
    Duration = 2.0;
  }
  if(Speed == 3){
    Duration = 1.0;
  }
  if(SpeedChange == 1) {
    readonly float CurrentProgress = IncreaseScaling.GetProgress();
    SpeedChange = 0;
    cTree.StopMoving();
    if (Speed !=0) {
      cTree.SetWalkSpeed(Speed*2, Speed*2);
      IncreaseScaling.Init(Duration - (Duration*CurrentProgress), CurrentTweenScaling, 300, eEaseInCircTween, eNoBlockTween);
    }
    cTree.Walk(500, 400, eNoBlock, eAnywhere);
    
  }


Thank you very much for any responses.

EDIT: added into this post a block of code I forgot to include in the above section.
J. They/them. Here are my most recent games:


Gilbert


edmundito

#6
@RootBound

Quote from: RootBound on Tue 02/05/2023 15:29:33OK, new problem. Can't figure out what I'm doing wrong in my scripting. Goal is to be able to pseudo change speed of tweens (including stopping and resuming) by doing the following:

1. getting the current fraction of tween's duration remaining through customtween.GetTweenProgress() and the current value through customtween.value.

2. stop the tween

3. start a new tween with the value and duration modified based on what was previously elapsed.

This is, however, not working. I have a label displaying the value of customtween.GetTweenProgress(which, if I understand correctly, is supposed to return a float value between 0 and 1), but instead the returned value almost instantaneously climbs to a 10-digit whole integer, and if the tween is paused and unpaused value returns to 0 (integer, not float) and stays there.

Any help would be greatly appreciated.


First, you can use the tween-provided function SecondsToLoops(1.0) to convert seconds to game loops instead of using GetGameSpeed() / 40. There's also a tween-provided function called SetTimerWithSeconds where youc can provide the number of seconds directly.

The problem I see in your code is that you're calling Update() only when the timer is expired:

Code: ags
  if (IsTimerExpired(1))  {
    SetTimer(1, GetGameSpeed()/40);
    if (IncreaseScaling.IsPlaying())  {
      IncreaseScaling.Update();
    }
    cTree.Scaling = IncreaseScaling.Value;
  }

Update needs to be called always because it only moves the tween one step on every loop. What I would recommend is do all your logic at the top of the function and then update the tween:

Code: ags
function repeatedly_execute_always() {
  if (IncreaseScaling.IsPlaying())  {
    IncreaseScaling.Update();
  }
  // Update object logic
  // Reset tween logic
}
The Tween Module now supports AGS 3.6.0!

RootBound

@edmundito Thank you, I will try these things out soon and see what happens.
J. They/them. Here are my most recent games:

AndreasBlack

#8
I'm unsure where to ask this, but this code doesn't seem to get any result anymore in AGS 3.6..
It doesn't give me any error's or something like that. It just doesn't pan out to the side's anymore. It was a nice effect to use! :~(

Code: ags
function region1_WalksOnto()
{
if (Ambient_Wind.IsPlaying)

{
Ambient_Wind.TweenPanning(0.3, 100);    //Right or Left side of the room

}


}



function region2_WalksOnto()
{
if (Ambient_Wind.IsPlaying)

{
Ambient_Wind.TweenPanning(0.3, -100);     //Right or Left side of the room
}


}


Crimson Wizard

Quote from: AndreasBlack on Tue 29/08/2023 14:29:17I'm unsure where to ask this, but this code doesn't seem to get any result anymore in AGS 3.6..
It doesn't give me any error's or something like that. It just doesn't pan out to the side's anymore. It was a nice effect to use!

What kind of a sound file are you using for this?
There's a known issue that stereo sounds can no longer be panned in 3.6.0, only mono ones.
Mostly this is because the stereo panning was not really a "panning" in previous versions, but another effect which coincidentally worked as if it were panning.

AndreasBlack

#10
Quote from: Crimson Wizard on Tue 29/08/2023 14:40:21
Quote from: AndreasBlack on Tue 29/08/2023 14:29:17I'm unsure where to ask this, but this code doesn't seem to get any result anymore in AGS 3.6..
It doesn't give me any error's or something like that. It just doesn't pan out to the side's anymore. It was a nice effect to use!

What kind of a sound file are you using for this?
There's a known issue that stereo sounds can no longer be panned in 3.6.0, only mono ones.
Mostly this is because the stereo panning was not really a "panning" in previous versions, but another effect which coincidentally worked as if it were panning.

I've been using both waves and ogg's this particular one seemed to be ogg 32bit floating stereo! So i'm converting it to Mono now, hold your butts! (nod)

Edit: Ogg mono, 32bit, works! Stereo would be nice ofc, but whatever it's just a ambient wind sound, not that important!

eri0o

The issue is upstream of us, here:

https://github.com/icculus/mojoAL/issues/12

There is an open PR there that adds an extension to mojoAL that would make it possible to do it. The discussion there explain the details.

AndreasBlack

Quote from: eri0o on Tue 29/08/2023 19:53:54The issue is upstream of us, here:

https://github.com/icculus/mojoAL/issues/12

There is an open PR there that adds an extension to mojoAL that would make it possible to do it. The discussion there explain the details.

Eri0o have you forgot who i am? I'm the guy that almost didn't get your experimental gamepad to work! (laugh) How's that going anyway any progress? I'll pass your suggestion, but thanks for letting me know! Mono works fine as for now. It's not that important since it's just an ambient wind sound! (nod)

Crimson Wizard

#13
Quote from: eri0o on Tue 29/08/2023 19:53:54There is an open PR there that adds an extension to mojoAL that would make it possible to do it.

If it's this PR then it does a logically different effect, and personally I believe it should not be activated by "Panning" function in AGS.

eri0o

Quote from: AndreasBlack on Tue 29/08/2023 20:06:47How's that going anyway any progress?

The work for the gamepad has been merged in ags4 and should be in the next alpha release of ags4! There is still work to do in that front, hopefully people play with it a bit there, and we see the things to add on top of the gamepad api, and what has to be improved/clarified then.

edmundito

For anyone intersted in providing donations or tips, I've updated the first post with my Ko-fi site: https://ko-fi.com/edmundito - This is greatly appreciated and may encourage me to keep working on the module!
The Tween Module now supports AGS 3.6.0!

AndreasBlack

Hey Edmundito, it would be nice if one could tween the animationdelay of objects & characters in floats. To be able to speed stuff up like Wheels, fans, various mechnical parts instead of using the view editor or manually Photoshop perhaps or code it (i had no clue where to begin). Just a suggestion!

Duration time for how long GUI's stay on screen is another one. Atm the very friendly eri0o cranked out something that does it for me, but it should be optional in the tween module in the future to set desired duration, since if i'm not mistakening you can do that in other tweens of the module. I use your module all the time btw, keep up the good work! (nod) 


kursh

Its amazingggggg, i was turning crazy to make a transition between 2 songs.. this is simply aaamaazingggg!!!!!!!!!!  8-0

thanks to the autor/s

SMF spam blocked by CleanTalk