Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Brian925 on Wed 07/02/2024 17:49:30

Title: Attempting to use function to utilize timer for multiple fade outs.
Post by: Brian925 on Wed 07/02/2024 17:49:30
I know the chances are slim, but I figured I'd check with the experts.

I have two announcement GUIs with generally the same look. I tried to be slick and create this function in the Global Script:
  function ingredient_announce() //an attempt to limit timers. //sends to 72 global
  {
  gAvoAnn.Visible=false; //resets first announcement
  gJalAnn.Visible=false; //resets second annoucement
  SetTimer(1, 180); //starts a timer
 
  if (avocado == 1){      //makes option 1 or 2 visible
    gAvoAnn.Visible=true;
    gAvoAnn.Transparency=0;
  }
   
   else if (jalapeno == 1){
   gJalAnn.Visible=true;
    gJalAnn.Transparency=0;
   }
     

Then when the timer expires, it calls to this in repeatedly execute in the global script:
   if(IsTimerExpired(1)){ //both avo and jala timers are expired if they have respectively been called.
    jalatimerdone=1;
    avotimerdone=1;

if (jalapeno == 1){
gJalAnn.TweenTransparency(0.2, 100, eNoBlockTween);}
  else if (avocado == 1){
  gAvoAnn.TweenTransparency(0.2, 100, eNoBlockTween);
  }}

In the room, the object you click on sets off the necessary variables and function with this code:
   avocado=1; //tells that avocado is in play, jalapeno would be jalapeno=1.
    ingredient_announce()

As expected, whatever I clicked first handled properly, but the next announcement would not fade although the proper announcement would pop up. I imagine this is because the timer has already been executed, so I was hoping there was a way to reset the timer each time an announcement is made.

To sum up:
1. Is it possible to reset the timer so it handles more than 1 image fade?
2. I have several announcements fading in this fashion...way more than 20. Am I out of luck in having more than 20 GUIs that fade out because each one requires a unique timer?





Title: Re: Attempting to use function to utilize timer for multiple fade outs.
Post by: Khris on Wed 07/02/2024 18:02:21
If an announcement GUI can get turned on while another one is still on screen, you'll need a separate timer for each one, yes.
However you do not need to use the built-in timers, you can simply count frames in repeatedly_execute instead (i.e. use variables).

I also doubt you need 20 GUIs for this; to show a graphic (or text) on screen you have various other methods available (like GUI buttons, or graphic overlays).

What is on these GUIs? Just text?

Anyway, I'd create a queue mechanism where each announcement is added when it happens and displayed at the top, pushing previous announcements down the screen. Inside rep_exe, the frame counters of visible announcements are advanced and the buttons / overlays removed when they expire.
Title: Re: Attempting to use function to utilize timer for multiple fade outs.
Post by: Brian925 on Wed 07/02/2024 18:33:58
Buttons totally slipped my mind, thank you. That should do the trick
Title: Re: Attempting to use function to utilize timer for multiple fade outs.
Post by: Brian925 on Thu 08/02/2024 17:14:21
Quote from: Khris on Wed 07/02/2024 18:02:21I also doubt you need 20 GUIs for this; to show a graphic (or text) on screen you have various other methods available (like GUI buttons, or graphic overlays).

Just a follow up to this: when I switched to GUI buttons, the images I'm using are now showing a subtle rectangular outline of the entire image when they fade to 100% transparency. Is that just to be expected with GUI buttons?
Title: Re: Attempting to use function to utilize timer for multiple fade outs.
Post by: Crimson Wizard on Thu 08/02/2024 17:24:30
Quote from: Brian925 on Thu 08/02/2024 17:14:21when I switched to GUI buttons, the images I'm using are now showing a subtle rectangular outline of the entire image when they fade to 100% transparency. Is that just to be expected with GUI buttons?

No, this is not supposed to happen.
Could you post a screenshot illustrating this problem?
Title: Re: Attempting to use function to utilize timer for multiple fade outs.
Post by: Brian925 on Fri 09/02/2024 18:53:46
Quote from: Crimson Wizard on Thu 08/02/2024 17:24:30
Quote from: Brian925 on Thu 08/02/2024 17:14:21when I switched to ...

No, this is not supposed to happen.
Could you post a screenshot illustrating this problem?


This is mid fade. The outline of the entire image suddenly shows up then disappears, ignoring transparency

https://imgur.com/a/FwGqhiB
Title: Re: Attempting to use function to utilize timer for multiple fade outs.
Post by: Crimson Wizard on Sat 10/02/2024 13:51:51
Quote from: Brian925 on Fri 09/02/2024 18:53:46This is mid fade. The outline of the entire image suddenly shows up then disappears, ignoring transparency

https://imgur.com/a/FwGqhiB

It's not entirely clear what do I see on this photograph; but supposing that the button is in the bottom-left corner, and that by "outline" you mean the whole greyish rectangle, then maybe this is caused by interface becoming disabled during the transparency change. If that's so, then this may be fixed by going to General Settings and changing value of "When player's interface is disabled, GUI should" to something else besides "Grey out".
Title: Re: Attempting to use function to utilize timer for multiple fade outs.
Post by: Brian925 on Sat 10/02/2024 21:14:20
that did it. Appreciate you!

....on an unrelated note, 76,000 views for this thread is odd lol
Title: Re: Attempting to use function to utilize timer for multiple fade outs.
Post by: Crimson Wizard on Sat 10/02/2024 21:38:39
Quote from: Brian925 on Sat 10/02/2024 21:14:20....on an unrelated note, 76,000 views for this thread is odd lol

I have a feeling that these view counters are broken. Or maybe it's a result of spam robots loading these pages.