Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Joe on Thu 31/03/2011 04:06:17

Title: Some way to make an animation while the room is fading in
Post by: Joe on Thu 31/03/2011 04:06:17
Hi again! Just as the title says... I want my character starts walking when the room starts fading in. I thought it could be possible using player.Walk(x,y,eNoBlock); in the player entres room before fade-in event. But when I test the game it waits till the room has fully faded in to start walking...

Thanks in advance.

Joe.
Title: Re: Some way to make an animation while the room is fading in
Post by: GarageGothic on Thu 31/03/2011 04:24:01
The default fade-in is a blocking function unfortunately. So you'll need to create your own non-blocking fade function. A solution that's worked well for me is to use a fullscreen GUI with black background color and fading it gradually in rep_exec_always. You can see my code here:

// Main script for module 'FadeNonBlocking'

int fadeintimer;
int fadeouttimer;
float fadetransparency;
float fademodifier;

function FadeInNonBlocking(int time) {
  fadetransparency = 0.0;
  fadeintimer = time;
  fademodifier = IntToFloat(100)/IntToFloat(time);
}

function FadeOutNonBlocking(int time) {
  fadetransparency = 100.0;
  fadeouttimer = time;
fademodifier = IntToFloat(100)/IntToFloat(time);
}


function repeatedly_execute_always() {
if (fadeintimer > 0) {
    fadetransparency = fadetransparency + fademodifier;
if (fadetransparency <= 100.0) gFadetoblack.Transparency = FloatToInt(fadetransparency);
else gFadetoblack.Transparency = 100;
    fadeintimer--;
    }
  else if (fadeouttimer > 0) {
    fadetransparency = fadetransparency - fademodifier;
if (fadetransparency >= 0.0) gFadetoblack.Transparency = FloatToInt(fadetransparency);
else gFadetoblack.Transparency = 0;
    fadeouttimer--;
    }
}
Title: Re: Some way to make an animation while the room is fading in
Post by: Joe on Thu 31/03/2011 12:55:13
Ok thanks! I was now trying to make some module but yours will be fine.
Title: Re: Some way to make an animation while the room is fading in
Post by: hedgefield on Thu 31/03/2011 15:51:19
You could also use the transparency function in the Tween Module (http://"http://www.adventuregamestudio.co.uk/yabb/index.php?topic=38015.0") with that black GUI, or even a black object the size of the screen, which will avoid any rep_ex business entirely.