I found this thread about the problem Im trying to solve, and I was wondering if there was any other way, or is this the best way to "replace" Wait() so its non-blocking?
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=40783.0
What Im doing is when a player receives damage, the health goes down and I display this change by changing the health bar sprite. Im making the bar go down in increments of 1, so say you lose 5 points, it goes down by 1 bar, 5 times...I decided to use Wait(5), seems to be the nicest wait time between sprite changes. The only down-side to this is that wait blocks, and I see my wait cursor flicker cause its constantly waiting and chaning sprites while in the function's loop. I could just render the cursor invisible duing the short Wait(5), but it would be even better to get around this another way all together.
So what Im asking is...what would some other options be (if any)?
You can use a counter to count down and the repeatedly_execute_always to change the bar.
int barDisplayCounter=5; //declare and initialize counter outside of functions
function repeatedly_execute_always(){
if(barDisplayCounter==0){
if(some expression that decides if the bar needs changing){
change the bar by one
}
barDisplayCounter=5; //reset the counter
}
else{
barDisplayCounter--; //count down
}
}
Rep ex always is your friend when you want to manually do non-blocking things.
Hey thanks! This post combined with extra help from Ryan got the job done :)
No prob, Bob.