Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Stapper on Tue 04/10/2016 05:47:28

Title: [Solved] Tween item pop-up halts the game
Post by: Stapper on Tue 04/10/2016 05:47:28
Hi all,

I've coded a general pop-up when picking up an item so that the player gets feedback it is added to their inventory using the Tween module. However it halts the entire script which is very inconvenient. I've tried with WaitSeconds and the Tween StartDelay, but neither of these continue the script. If I remove the eNoBlockTween it doesn't wait at all to show the item and just eases in and out immediately.

Does anyone know a way to still show the item for 3 seconds before easing out the pop-up without halting the game?

Code (ags) Select
function InvPopAdd(int item)
{
  gInvPopup.SetPosition(-79, 569);
  gInvPopup.Visible = true;
  btnInvPop.NormalGraphic = item;
  gInvPopup.TweenX(0.3, 0, eEaseOutSineTween);
  //WaitSeconds(3.0); //has same result as below
  gInvPopup.TweenY(0.6, 768, eEaseOutSineTween, eNoBlockTween, 3.0);
  gInvPopup.Visible = false; 
}
Title: Re: Tween item pop-up halts the game
Post by: CaesarCub on Tue 04/10/2016 11:08:02

I think the first thing you should check the GUI Visibility property to make sure that it's on "Normal, initially off" and not on "Pause game when shown".
Otherwise the game will pause the moment the pop-up shows up.
Title: Re: Tween item pop-up halts the game
Post by: Khris on Tue 04/10/2016 20:04:55
You need this:
function InvPopAdd(int item)
{
  gInvPopup.SetPosition(-79, 569);
  gInvPopup.Visible = true;
  btnInvPop.NormalGraphic = item;
  gInvPopup.TweenX(0.3, 0, eEaseOutSineTween, eNoBlockTween, 3.0);
  SetTimer(1, 3 * GetGameSpeed());  // schedule removing the popup
}

// in repeatedly_execute_always
  if (IsTimerExpired(1)) {
      gInvPopup.TweenY(0.6, 768, eEaseOutSineTween, eNoBlockTween, 3.0);
  }

Title: Re: Tween item pop-up halts the game
Post by: Stapper on Fri 07/10/2016 00:56:24
Thanks!