GUI movement without blocking (SOLVED)

Started by Sackboy, Sat 12/01/2013 14:54:47

Previous topic - Next topic

Sackboy

i want to create something like the floating numbers during a battle sequence of a rpg. for that i created a GUI with just one label on it. the label can display any random number. the GUI itself is only visible on certain events. if the GUI is visible the following should happen:

- GUI moves up steadily
- GUI slowly becomes more transparent

here is part of the code i use:

Code: AGS
GUI.Visible=true;

int x=0;

while(x<50){

  GUI.Y=GUI.Y-5;
  GUI.Transparency=GUI.Transparency+2;

  x++;

  Wait(1);

}

GUI.Visible=false;


nothing fancy. the problem i have is that this function is blocking because of "Wait(1);". but if i run it without "Wait(1);" i don't see anything. it's like what happens in the while loop is not displayed.
i am searching for a way to make this code not blocking the game so that the player can still move while the GUI rises up and becomes more and more invisible. would be great if anyone could help me with that. thank you!

Khris

What you would normally do is put a check inside the repeatedly_execute function and advance the GUI's state in there. This will change the GUI's appearance and position without blocking the game.
Basically, repeatedly_execute is an infinite while loop that runs during the entire game.

However, there's a module that does exactly what you want called Tween module.
Using it, you can get the effect you want with a single line of code.

Sackboy

wow, that was fast. thank you sir!  :)

SMF spam blocked by CleanTalk