Can I create a dSprite, draw it and delete it without affecting the surface?

Started by bx83, Thu 15/04/2021 12:58:57

Previous topic - Next topic

bx83

I have a picture. I can turn it into a dynamic sprite, and draw it wherever I want.
But I can't delete it, as it's burnt into the background.
I can take a square of background from before drawing and re-apply it to hide the sprite - but if it's the background is being animated at the time I take the copy, this will write back the wrong image.
What do I do? Is there any way of showing/hiding an image without just using the GUI/Object 'Visible' method?

Khris

At some point you will have to familiarize yourself with the different graphical layers AGS uses.

When you say "background", are we talking about the room background? How exactly is it animated? Background animations frames? An object?

Also, what you describe sounds like you want a Graphic Overlay? Something that appears above the background, can be removed at any time, but is covered by GUIs.

bx83

'Background' meaning room background, overwritten dynamically by animated objects and background animation.
Graphic Overlays sound useful - I will investigate.
The last chance I got, I used one to display a timer on-screen (take value of time left, write it out, pace on. overlay, put on screen top-left) -- BUT it crashed after 40 loops with 'too many overlays', and I gave up.
Do you know of a good tutorial?

Khris

Sounds like you kept calling the command, creating a new Overlay each frame.
I don't think that you can change an existing Graphical Overlay's graphic,so your approach was correct in principle. All you need to do is delete the existing one, if it exists.

Code: ags
Overlay* ovTimer;  // above the function that's using it

  // inside the repeatedly execute type function
  if (ovTimer != null && ovTimer.Valid) timer.Remove();
  ovTimer = Overlay.CreateGraphical(...);

bx83


SMF spam blocked by CleanTalk