Hi,
I have this function, which I want to be able to repeat in a loop. It needs to do its thing without blocking - so the player can click on things at the same time.
Basically all it's doing is moving a line of text down the page - 1 pixel every second - until it gets to a certain y value.
This is the code I tried to write so it didn't block:
Code: ags
Except that doesn't work just locks the game up. The only way to fix it is to add a Wait(1) - but that destroys the point.
Code: ags
Help - this is integral to getting the game working! Thanks, Mark.
I have this function, which I want to be able to repeat in a loop. It needs to do its thing without blocking - so the player can click on things at the same time.
Basically all it's doing is moving a line of text down the page - 1 pixel every second - until it gets to a certain y value.
This is the code I tried to write so it didn't block:
function ScrollSentence(int speed = 40)
{
int timer = 0;
sentence = Overlay.CreateTextual(134, 36, 80, Game.SpeechFont, 15, "Sentence 1");
while (sentence.Y < 108) {
timer++;
if (timer == speed) {
sentence.Y++;
timer = 0;
}
}
sentence.Remove();
}
Except that doesn't work just locks the game up. The only way to fix it is to add a Wait(1) - but that destroys the point.
function ScrollSentence(int speed)
{
int timer = 0;
//determine what "sentence one" from lists
sentence = Overlay.CreateTextual(134, 36, 80, Game.SpeechFont, 15, "Sentence 1");
while (sentence.Y < 108) {
timer++;
if (timer == 40) {
sentence.Y++;
timer = 0;
}
Wait(1);
}
sentence.Remove();
}
Help - this is integral to getting the game working! Thanks, Mark.