Page 1 of 1

Is It possible to clear WaitEvent() in middle of event?

Posted: Sun Apr 28, 2013 12:47 pm
by Bugala
I was first making the ingame things and was using WaitEvent() for things.

However, Now I finally made a Titlescreen test and came into bit of a problem.

I use WaitEvent to check if "startgame" button is pressed, and if so, then it starts the game. Since InGame also has WaitEvent() inside it, it means that the ingame waitevent is called inside another waitevent, and hence error quits the program.

I already made the program so that it uses the same waitevent command for titlescreen as well as ingame stuff, but I am bit worried about my current solution and think that it would be safer if I could use own Waitevent inside the ingame function.

Is there therefore a way to clear current waitevent and preferably without exiting the current waitevent event.

For what I am hoping to be able to do is that when InGame event is woke up, its first line would be something like "ClearEvents()" and after that when next WaitEvent() comes, it would be the only WaitEvent() in execution.

Re: Is It possible to clear WaitEvent() in middle of event?

Posted: Wed May 01, 2013 11:34 am
by airsoftsoftwair
Bugala wrote:I already made the program so that it uses the same waitevent command for titlescreen as well as ingame stuff, but I am bit worried about my current solution and think that it would be safer if I could use own Waitevent inside the ingame function.
No, you should always only use a single WaitEvent() call for your main loop. It's possible. Just set some flags that indicate whether you are in game or menu mode. Calling WaitEvent() from event handlers invoked by WaitEvent() is very bad practice and Hollywood will not allow this.