Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: LupaShiva on Tue 21/12/2010 18:41:55

Title: Gui timer
Post by: LupaShiva on Tue 21/12/2010 18:41:55
Hello everybody, im having a problem, i wanted to create a GUI with a text label that for example when u take an object it appears "New object taken" and after few seconds it dissapears, but im getting stuck with it, what i should use SetTimer?
Title: Re: Gui timer
Post by: Khris on Tue 21/12/2010 20:43:05
What exactly is the problem?

SetTimer needs a number and the amount of frames. By default, the game speed is 40 frames per second, so to show the GUI for two seconds, use e.g. SetTimer(1, 80);

In repeatedly_execute() in Global.asc you need to check if the timer has expired:

  if (IsTimerExpired(1)) gObjectTaken.Visible = false;

Note that adding something to the inventory calls on_event(eEventAddInventory, item.ID) (http://www.adventuregamestudio.co.uk/manual/TextScriptEvents.htm) so you could add this to Global.asc:

function on_event (EventType event, int data) {
  if (event == eEventAddInventory) {
    bObjectTaken.NormalImage = inventory[data].Graphic;
    SetTimer(1, 80);
    gObjectTaken.Visible = true;
  }
}
Title: Re: Gui timer
Post by: LupaShiva on Thu 23/12/2010 01:35:47
OHH Thank you, already tryed and it worked with setimer, i didnt put the global.asc , now it works thank you and sorry about my english  :)