Tween interfering with setting of property

Started by Laura Hunt, Sun 10/05/2020 20:28:35

Previous topic - Next topic

Laura Hunt

I'm having a weird issue in which sometimes, after using a tween to fade in/out an object's transparency or volume value, that value can't be set anymore through the use of the "regular" (non-tweened) property.

In this very simple example, I want an object to appear out of nothing at transparency 40, and then fade out:


Code: ags
function region13_WalksOnto()
{
      oObject1.Transparency = 40;
      player.Say("Did I see something there?");
      oObject1.TweenTransparency(0.5, 100, eEaseLinearTween, eNoBlockTween);
      player.Walk(155, 234, eBlock);  // moves character outside of region13
}


The first time the player walks on the region, everything works well. But if you step into the region again, the object does not appear, and furthermore, other attempts to change its transparency using oObject1.Transparency = whatever stop working too. It's as if the tween had "locked" this object's transparency at 100 and now I can only change it again using tweens. So if I do this, now it works:

Code: ags
function region13_WalksOnto()
{
      oObject1.TweenTransparency(0.5, 40, eEaseLinearTween, eNoBlockTween);
      player.Say("Did I see something there?");
      oObject1.TweenTransparency(0.5, 100, eEaseLinearTween, eNoBlockTween);
      player.Walk(155, 234, eBlock);  // moves character outside of region13
}


Has this happened to anybody? Is this a known bug, by any chance?

Edit: I'm using AGS 3.4.3.1 with Tween module 2.1.0.

Snarky

If I recall correctly, you cannot in fact set .Transparency = 100, you must instead set .Visible = false. So is it possible that the Tween module does this under the hood in order to achieve total transparency? Then if .Visible is set to false, changing the transparency won't make a difference until you turn visibility back on.

Laura Hunt

Quote from: Snarky on Sun 10/05/2020 20:52:15
If I recall correctly, you cannot in fact set .Transparency = 100, you must instead set .Visible = false. So is it possible that the Tween module does this under the hood in order to achieve total transparency? Then if .Visible is set to false, changing the transparency won't make a difference until you turn visibility back on.

That's interesting... I've used .Transparency = 100 in many occasions and it works perfectly, but maybe the Tween module does indeed set a .Visible = false flag under the hood. Let me give this a try and I'll report back!

Crimson Wizard

Transparency property can be set to 100.

Laura Hunt

omg it worked! Awesome, thanks ;-D

HOWEVER

This has also happened to me with characters, and characters as far as I know don't have a .Visible property. What could be happening in this case?

Crimson Wizard

Does this mean that tween module is not done right? Why does it silently change another property?

Laura Hunt

#6
Quote from: Crimson Wizard on Sun 10/05/2020 21:20:08
Does this mean that tween module is not done right? Why does it silently change another property?

That's what it looks like...

Code: ags
  else if (this.Type == _eTweenObjectTransparency) {
    Object *objectRef = object[this.RefID];
    if (this.Elapsed == 0.0 && objectRef.Visible == false && objectRef.Transparency == 100) {
      objectRef.Visible = true;
    }
    objectRef.Transparency = TweenMaths.ClampInt(TweenMaths.Lerp(this.FromValue, this.ToValue, amount), 0, 100);
    if (this.Elapsed == this.Duration && objectRef.Visible == true && objectRef.Transparency == 100) {
      objectRef.Visible = false;
    }
  }


However, I haven't found anything in the code that suggests it does something similar with characters, so I'm at a complete loss as to why it also happens sometimes in those cases. But hey, a mystery solved, at least.

SMF spam blocked by CleanTalk