Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: PEd1 on Sun 25/02/2024 13:39:21

Title: Background animation motionless until fade-in has finished
Post by: PEd1 on Sun 25/02/2024 13:39:21
So I have background animations and in "General Settings" I have "Default transition when changing rooms" set to "FadeOutAndIn"... (I am using the Tumbleweed template btw).

When my player enters the room, the animation is motionless during the fade-in (and any animations in the previous room are motionless during the fade-out of that room).

If I change the transition to "Instant" everything is moving right away...

Is there any way to have the FadeOutAndIn, but where the animations are already moving while the scene fades in?
Title: Re: Background animation motionless until fade-in has finished
Post by: Crimson Wizard on Mon 26/02/2024 02:22:40
Default AGS transitions are blocking everything in the room, including background animations. Maybe this is not a particularly good design, but so it is right now.

If you like a different behavior, then make your own transition effect:
1. Set AGS transition to Instant.
2. Create a empty fullscreen GUI with black background.
3. In "before fade-in" event set GUI visible and Transparency 0.
4. In "after fade-in" event emulate fading effect changing GUI's Transparency from 0 to 100 in a loop, and remove it completely after with Visible = false.

Use "on_event" global function in GlobalScript instead of room events, this way you won't have to repeat same code in each room:
https://adventuregamestudio.github.io/ags-manual/Globalfunctions_Event.html#on_event

Code (ags) Select
function on_event(int event, int data)
{
    if (event == eEventEnterRoomBeforeFadein)
    {
        gFadeOut.Visible = true;
        gFadeOut.Transparency = 0;
    }
    else if (event == eEventEnterRoomAfterFadein )
    {
        while (gFadeOut.Transparency < 100)
        {
            // adjust numbers to change the fade-in speed
            gFadeOut.Transparency = gFadeOut.Transparency + 2;
            Wait(1);
        }
        gFadeOut.Visible = false;
    }
}

You may do opposite (fadeout) effect on eEventLeaveRoom event.
Title: Re: Background animation motionless until fade-in has finished
Post by: PEd1 on Mon 26/02/2024 12:29:01
Excellent, thanks!

Quote from: Crimson Wizard on Mon 26/02/2024 02:22:40Default AGS transitions are blocking everything in the room, including background animations. Maybe this is not a particularly good design, but so it is right now.

It's just a minor/subtle thing, and I think I'm noticing it more because I just added animations, so I'm very aware of them...
I think most players either don't notice, or they know it's the scene fading-in before everything is "live" in the room.

Though it's great to also have this option to alter it if necessary, thanks!