How to make a room fade in slowly?

Started by Gribbler, Sat 13/04/2013 19:33:18

Previous topic - Next topic

Gribbler

Hi guys!

I'm trying to make one room appear slowly with FadeIn (set at 10). But I just can't quite figure out where to put the code, in which room event? None works. With FadeOut it's simple - you just put it right before ChangeRoom. But FadeIn? I searched the forums and found only some complicated solutions with transparent guis, big black objects fading out and whatnot. I mean, c'mon. Itn't there a simpler way?

Khris

Did a quick test to try a workaround, but the screen of the new room still flashes briefly before fading in.
The speed of room transition fading seems to be hard coded; so I guess a big black GUI it is.

Code: ags
// room_Load:
  gBlack.Visible = true;
  FadeOut(64);

// after fadein
  gBlack.Visibe = false;
  FadeIn(10);

Cerno

That is in fact very useful and simple.
I was running into the exact same problem here and thought I had to mess about with Transparency here, but apparently all you need is a blocker to hide AGS's automatic fade in which is impossible to prevent.

Thanks for the idea.
123  Currently working on: Sibun - Shadow of the Septemplicon

Gribbler

Hmmm, it doesn't seem to work for me. Room still flashes briefly before fade in. My room events code is:

Code: AGS

function room_Load()
{
gBlack.Visible = true;
FadeOut(64);
mouse.Mode = eModePointer;
Mouse.DisableMode(eModeInteract);
Mouse.DisableMode(eModeLookat);
mouse.DisableMode(eModeTalkto);
mouse.DisableMode(eModeWait);
mouse.DisableMode(eModeWalkto);
gInventory.Visible = false;
gIconbar.Visible = false;
object[3].Clickable = false;
object[4].Clickable = false;
object[5].Clickable = false;
}

function room_AfterFadeIn()
{
gBlack.Visible = false;
FadeIn(1);

mouse.Visible = false;
  Wait(40);
  object[3].Visible = true;
int trans = object[3].Transparency;
while (trans < 100) {
  trans += 5;
  object[3].Transparency = 100-trans;
  Wait(1);
  }
object[4].Visible = true;
int trans1 = object[4].Transparency;
while (trans1 < 100) {
  trans1 += 5;
  object[4].Transparency = 100-trans1;
  Wait(1);
  }
object[5].Visible = true;
int trans2 = object[5].Transparency;
while (trans2 < 100) {
  trans2 += 5;
  object[5].Transparency = 100-trans2;
  Wait(1);
  }
mouse.Visible = true;
}


I have a big full screen black gui (bakcground color 0;0;0;) set to "Normal, initially off", transparency 0. Transparent objects fading slowly in are main title options buttons which I want to appear slowly after slow room fade in.

Khris

Try turning on the black GUI in the previous room.

Gribbler

Darn, it does not work either. I tried with both background colour set to black and with a black image (320x200) as gui. But strange thing happens, now I can see slow fade in on the cursor, it appears slowly and after that room appears instantly. I just don't get it... Whan can I be doing wrong?

Gribbler

Yay! I did it! I made it with big black 320x200 object initially set to visible which fades out after room fade in:

Code: AGS

function room_AfterFadeIn()
{
Wait(40);
int trans3 = object[6].Transparency;
while (trans3 < 100) {
  trans3++;
  object[6].Transparency = trans3;
  Wait(1);
  object[6].Clickable = false;
}


I guess FadeIn function is pretty much useless when it comes to room changing.

Thank you Khris for all the help.

kaput

A very simple way to do this would be:

In the general settings, set default transition when fading rooms to instant. Then assign your own Fadein's in each room's room_load events.

It's not that much work, really. Your fadein's won't work in Direct5 so you'll have to make your game Direct3d.

Hope this works for you. If I'm wrong about anything I'm sure someone will correct me! But yeah, this works.

Cerno

#8
Gribbler, I think Khris's way is still easier than your solution and it works for me, so you may want to review your previous attempt, maybe something went wrong somewhere.
Just in case you use this more often, I guess doing it in 4 lines might be easier and less fiddly than having to add an object to each room that you want to use this in.
Out of curiosity, are you switching the object to non-transparent in the room_load function or have you found another way of keeping the room black before fade in?

Nevermind, I missed the part of the discussion where that doesn't work for you.
I hope I won't run into trouble with my implementation ;)
123  Currently working on: Sibun - Shadow of the Septemplicon

Khris

Did a bit more testing:

This method works in both display modes, provided that gBlack is turned on before leaving the previous room (Screen Transition: instant).
Code: ags
// after fadein
  FadeOut(64);
  gBlack.Visible = false;
  Wait(1);  // without this, the GUI isn't turned off before the fading!
  FadeIn(1);


I have also noticed that the speed varies depending on the graphics driver... (roll)
DirectDraw seems to fade faster than Direct3D.

Also, I can confirm Sunny Penguin's suggestion; apparently, calling FadeIn() in before fadein/room_Load works in Direct3D mode (although it shouldn't).
On the other hand, a proper solution shouldn't use an object nor rely on the user not being able to change the display driver.

Let's hope that this is addressed in AGS 3.3.

Sylvr

The first thing I thought of when I read the title of the thread was "Tween Module", why wouldn't that work here? Or is that just for objects?
| Ben304: "Peeing is a beautiful thing, Sylvr" |

Slasher

I think they were trying to see if that way would worked.

The Tween can fade in / out GUI's as well, I 'v used it.

SMF spam blocked by CleanTalk