Overlays segfaulting

Started by bx83, Tue 08/08/2017 08:33:29

Previous topic - Next topic

bx83

Hi,

I recently discovered Overlays for writing text on screen. However, they only go for a few secnods, and cause a runtime error. So:

for (...) {
    set an overlay
}

Presumably this writes it every frame and then overflows; but how can be done any other way? If I want to display a timer, or a variable, do I always have to add "if (value has changed) { draw an overlay }" ?

Khris

You have created a new Overlay 40 times per second.

This is explained right in the manual:
QuoteA screen overlay looks identical to the way speech text is displayed in conversations, except that with this command the text stays on the screen until either you remove it with the Remove command, or the player goes to a different room, in which case it is automatically removed.

To change the text, you can do this:
Code: ags
// above rep_Exec
Overlay *timer;

  // in rep_Exec
  if (timer == null) timer = Overlay.CreateTextual(...);
  else timer.SetText(...);


If you want to display text that's supposed to change all the time, a label on a GUI might be the better solution.

Crimson Wizard

#2
Could you clarify just in case, is there an actual "segmentation fault" error reported, or a common "too many overlays" script error?

Thing is that real segfault error would indicate there is a bad error in the engine, not only script.

bx83

"Too many overlays" error, I couldn't remember so I said segfault.

SMF spam blocked by CleanTalk