Gui timer

Started by LupaShiva, Tue 21/12/2010 18:41:55

Previous topic - Next topic

LupaShiva

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?

Khris

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:

Code: ags
  if (IsTimerExpired(1)) gObjectTaken.Visible = false;


Note that adding something to the inventory calls on_event(eEventAddInventory, item.ID) so you could add this to Global.asc:

Code: ags
function on_event (EventType event, int data) {
  if (event == eEventAddInventory) {
    bObjectTaken.NormalImage = inventory[data].Graphic;
    SetTimer(1, 80);
    gObjectTaken.Visible = true;
  }
}

LupaShiva

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  :)

SMF spam blocked by CleanTalk