Trouble with timers/overlay ... [SOLVED]

Started by DrewCCU, Fri 07/05/2010 01:38:00

Previous topic - Next topic

DrewCCU

Hey guys, i'm back (sorry so quickly lol)

Maybe my brain is just tired but this seems like it should be a hell of a lot easier than it is turning out to be ... anyway - the issue:

If (something) {
   text overlay displays
}

however, i only want that overlay to display for one second then go away.  Keep in mind, please, that I do not want to use the wait command because I do not want other scripting to halt. Also, keep in mind that this will not (and can not) go in the RepExec section of the script. (it is currently in a hotspot interaction part of the script)

Again, I know this is probably simple ... but my brain gave me the finger so i'm turning to you guys for your help. Thanks.
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

Dualnames

Quote from: DrewCCU on Fri 07/05/2010 01:38:00
Hey guys, i'm back (sorry so quickly lol)

Maybe my brain is just tired but this seems like it should be a hell of a lot easier than it is turning out to be ... anyway - the issue:

If (something) {
    text overlay displays
}

however, i only want that overlay to display for one second then go away.  Keep in mind, please, that I do not want to use the wait command because I do not want other scripting to halt. Also, keep in mind that this will not (and can not) go in the RepExec section of the script. (it is currently in a hotspot interaction part of the script)

Again, I know this is probably simple ... but my brain gave me the finger so i'm turning to you guys for your help. Thanks.

I'm guessing it's a text overlay.

Code: ags

if (something) {
Overlay* myOverlay = Overlay.CreateTextual(50,80,120, Game.SpeechFont, 15,"This is a text overlay");
Wait(40);
myOverlay.Remove();
}


http://www.adventuregamestudio.co.uk/manual/Overlay.CreateTextual.htm
http://www.adventuregamestudio.co.uk/manual/Overlay.CreateGraphical.htm
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

DrewCCU

Quote from: Dualnames on Fri 07/05/2010 01:42:18
Quote from: DrewCCU on Fri 07/05/2010 01:38:00
Hey guys, i'm back (sorry so quickly lol)

Maybe my brain is just tired but this seems like it should be a hell of a lot easier than it is turning out to be ... anyway - the issue:

If (something) {
    text overlay displays
}

however, i only want that overlay to display for one second then go away.  Keep in mind, please, that I do not want to use the wait command because I do not want other scripting to halt. Also, keep in mind that this will not (and can not) go in the RepExec section of the script. (it is currently in a hotspot interaction part of the script)

Again, I know this is probably simple ... but my brain gave me the finger so i'm turning to you guys for your help. Thanks.

I'm guessing it's a text overlay.

Code: ags

if (something) {
Overlay* myOverlay = Overlay.CreateTextual(50,80,120, Game.SpeechFont, 15,"This is a text overlay");
Wait(40);
myOverlay.Remove();
}


http://www.adventuregamestudio.co.uk/manual/Overlay.CreateTextual.htm
http://www.adventuregamestudio.co.uk/manual/Overlay.CreateGraphical.htm

I don't want to use the Wait command because i do not want scripting to halt while this text is displayed. Yes. it is a text overlay.
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

Dualnames


Code: ags

int sth;
if (something) {
Overlay* myOverlay = Overlay.CreateTextual(50,80,120, Game.SpeechFont, 15,"This is a text overlay");
while (sth!=40) {
sth++;
}
myOverlay.Remove();
}
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Gilbert

Dual, that won't work. The while loop just contributes nothing to the game's elapsed time. It's still in that single frame of display.

1. The overlay pointer has to be declared outside of any function, otherwise it would be destroyed once the function finished executing.
Code: ags

Overlay* myOverlay;


2. At where you want stuff to happen:
Code: ags

if (something) {
  MyOverlay = Overlay.CreateTextual(50,80,120, Game.SpeechFont, 15,"This is a text overlay");
  SetTimer (1, 40);
}


3. Then in repeatedly_execute[_always]():
Code: ags

  if (IsTimerExpired(1)) myOverlay.Remove();


Dualnames

Right my bad, indeed. Gilbet is 100% right. Gah, I'm so fast sometimes, I forgot to think.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

DrewCCU

Quote from: Gilbet V7000a on Fri 07/05/2010 01:49:41
Dual, that won't work. The while loop just contributes nothing to the game's elapsed time. It's still in that single frame of display.

1. The overlay pointer has to be declared outside of any function, otherwise it would be destroyed once the function finished executing.
Code: ags

Overlay* myOverlay;


2. At where you want stuff to happen:
Code: ags

if (something) {
  MyOverlay = Overlay.CreateTextual(50,80,120, Game.SpeechFont, 15,"This is a text overlay");
  SetTimer (1, 40);
}


3. Then in repeatedly_execute[_always]():
Code: ags

  if (IsTimerExpired(1)) myOverlay.Remove();



ah thanks. you guys rock.
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

SMF spam blocked by CleanTalk