Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: m0rph84 on Sun 19/02/2017 22:13:01

Title: Multiple Background without automatic looping
Post by: m0rph84 on Sun 19/02/2017 22:13:01
Hello,
I thought it was simple to achieve but I was wrong  :smiley:
I've no idea how to load multiple backgrounds without making AGS automatically looping them.
I can't find anything on the manual or in the forum.
What I want to obtain is to load, after the user clicks on a specific object, a completely red background
with the DrawSurface function on the top of the main background with a certain degree of transparency and for a certain number of seconds:

DrawingSurface.DrawSurface(DrawingSurface *source, optional int transparency)

I have also the Tween module installed...I don't know if there is a simpler way to achieve that with it...
Title: Re: Multiple Background without automatic looping
Post by: Crimson Wizard on Sun 19/02/2017 22:18:26
Quote from: m0rph84 on Sun 19/02/2017 22:13:01
I've no idea how to load multiple backgrounds without making AGS automatically looping them.
Simply use SetBackgroundFrame function, it locks room background at certain frame.


EDIT: actually...
Quote from: m0rph84 on Sun 19/02/2017 22:13:01
What I want to obtain is to load, after the user clicks on a specific object, a completely red background
with the DrawSurface function on the top of the main background with a certain degree of transparency and for a certain number of seconds:

if you want to make a red overlay over room, you could use SetAmbientTint function instead.
Title: Re: Multiple Background without automatic looping
Post by: m0rph84 on Sun 19/02/2017 22:53:58
Thanks a lot!
Now I'm able to lock and switch backgrounds.

Quoteif you want to make a red overlay over room, you could use SetAmbientTint function instead.

Actually, I just tried SetAmbientTint but it apply only to characters and objects, I need the red tint to be applied also
to the whole background (I want to obtain an "hit damage" effect).

Any suggestion?
Title: Re: Multiple Background without automatic looping
Post by: Crimson Wizard on Sun 19/02/2017 23:19:43
Two background frames would work too, but if you have large scrolling room, or multiple rooms where you'd like to have same effect, painting on same background will work better:

Make global DynamicSprite variable, save original room background there, upon room load:

Code (ags) Select

DynamicSprite *SavedBkg;

...

function Room_OnLoad()
{
    SavedBkg = DynamicSprite.CreateFromBackground(0);
}


When you need to change room background to red, get DrawingSurface from that frame and draw effect upon it. Then restore background by painting saved sprite on it.
Title: Re: Multiple Background without automatic looping
Post by: Snarky on Mon 20/02/2017 00:00:56
If you want to tint everything on screen red, instead of messing around with drawing on the background I would simply put a semi-transparent, non-clickable red GUI over the whole screen.
Title: Re: Multiple Background without automatic looping
Post by: Crimson Wizard on Mon 20/02/2017 00:05:52
Quote from: m0rph84 on Sun 19/02/2017 22:53:58
Actually, I just tried SetAmbientTint but it apply only to characters and objects, I need the red tint to be applied also
to the whole background (I want to obtain an "hit damage" effect).
Quote from: Snarky on Mon 20/02/2017 00:00:56
If you want to tint everything on screen red, instead of messing around with drawing on the background I would simply put a semi-transparent, non-clickable red GUI over the whole screen.

Oh, I actually misread that m0rph84 wanted to make both background and characters tinted.
Yes, in that case transparent GUI or Overlay is better.

PS. I think I also confused SetAmbientTint with SetFadeColor/FadeIn function, because I thought that SetAmbientTint also works on background.
Title: Re: Multiple Background without automatic looping
Post by: Snarky on Mon 20/02/2017 00:17:45
... and then you can use the Tween module to "flash" red (by quickly fading the GUI in and fading it out more slowly), which I think is the effect you're looking for.
Title: Re: Multiple Background without automatic looping
Post by: m0rph84 on Mon 20/02/2017 00:42:45
Perfect!

Thank you both.
I think the non-clickable red GUI is what I was looking for.

This is an amazing community!
Thanks again.