Some way to make an animation while the room is fading in

Started by Joe, Thu 31/03/2011 04:06:17

Previous topic - Next topic

Joe

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.
Copinstar © Oficial Site

GarageGothic

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:

Code: ags
// 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--;
    }
}

Joe

Ok thanks! I was now trying to make some module but yours will be fine.
Copinstar © Oficial Site

hedgefield

You could also use the transparency function in the Tween Module with that black GUI, or even a black object the size of the screen, which will avoid any rep_ex business entirely.

SMF spam blocked by CleanTalk