Author Topic: How to make a room fade in slowly?  (Read 2873 times)

Gribbler

  • Posts: 1,489
  • I'm selling these fine leather jackets.
    • Gribbler worked on a game that won an AGS Award!
    •  
    • Gribbler worked on a game that was nominated for an AGS Award!
How to make a room fade in slowly?
« on: 13 Apr 2013, 19:33 »
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

  • Posts: 10,676
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: How to make a room fade in slowly?
« Reply #1 on: 14 Apr 2013, 10:36 »
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: Adventure Game Studio
  1. // room_Load:
  2.   gBlack.Visible = true;
  3.   FadeOut(64);
  4.  
  5. // after fadein
  6.   gBlack.Visibe = false;
  7.   FadeIn(10);

Cerno

  • Posts: 195
  • Animating kills me
Re: How to make a room fade in slowly?
« Reply #2 on: 14 Apr 2013, 12:19 »
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.
  Currently working on: Sibun - Shadow of the Septemplicon

Gribbler

  • Posts: 1,489
  • I'm selling these fine leather jackets.
    • Gribbler worked on a game that won an AGS Award!
    •  
    • Gribbler worked on a game that was nominated for an AGS Award!
Re: How to make a room fade in slowly?
« Reply #3 on: 14 Apr 2013, 13:55 »
Hmmm, it doesn't seem to work for me. Room still flashes briefly before fade in. My room events code is:

Code: Adventure Game Studio
  1. function room_Load()
  2. {
  3. gBlack.Visible = true;
  4. FadeOut(64);
  5. mouse.Mode = eModePointer;
  6. Mouse.DisableMode(eModeInteract);
  7. Mouse.DisableMode(eModeLookat);
  8. mouse.DisableMode(eModeTalkto);
  9. mouse.DisableMode(eModeWait);
  10. mouse.DisableMode(eModeWalkto);
  11. gInventory.Visible = false;
  12. gIconbar.Visible = false;
  13. object[3].Clickable = false;
  14. object[4].Clickable = false;
  15. object[5].Clickable = false;
  16. }
  17.  
  18. function room_AfterFadeIn()
  19. {
  20. gBlack.Visible = false;
  21. FadeIn(1);
  22.  
  23. mouse.Visible = false;
  24.   Wait(40);
  25.   object[3].Visible = true;
  26. int trans = object[3].Transparency;
  27. while (trans < 100) {
  28.   trans += 5;
  29.   object[3].Transparency = 100-trans;
  30.   Wait(1);
  31.   }
  32. object[4].Visible = true;
  33. int trans1 = object[4].Transparency;
  34. while (trans1 < 100) {
  35.   trans1 += 5;
  36.   object[4].Transparency = 100-trans1;
  37.   Wait(1);
  38.   }
  39. object[5].Visible = true;
  40. int trans2 = object[5].Transparency;
  41. while (trans2 < 100) {
  42.   trans2 += 5;
  43.   object[5].Transparency = 100-trans2;
  44.   Wait(1);
  45.   }
  46. mouse.Visible = true;
  47. }
  48.  

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

  • Posts: 10,676
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: How to make a room fade in slowly?
« Reply #4 on: 14 Apr 2013, 14:30 »
Try turning on the black GUI in the previous room.

Gribbler

  • Posts: 1,489
  • I'm selling these fine leather jackets.
    • Gribbler worked on a game that won an AGS Award!
    •  
    • Gribbler worked on a game that was nominated for an AGS Award!
Re: How to make a room fade in slowly?
« Reply #5 on: 14 Apr 2013, 17:22 »
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

  • Posts: 1,489
  • I'm selling these fine leather jackets.
    • Gribbler worked on a game that won an AGS Award!
    •  
    • Gribbler worked on a game that was nominated for an AGS Award!
Re: How to make a room fade in slowly?
« Reply #6 on: 14 Apr 2013, 17:53 »
Yay! I did it! I made it with big black 320x200 object initially set to visible which fades out after room fade in:

Code: Adventure Game Studio
  1. function room_AfterFadeIn()
  2. {
  3. Wait(40);
  4. int trans3 = object[6].Transparency;
  5. while (trans3 < 100) {
  6.   trans3++;
  7.   object[6].Transparency = trans3;
  8.   Wait(1);
  9.   object[6].Clickable = false;
  10. }
  11.  

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

Thank you Khris for all the help.

Mikeg

  • Posts: 477
Re: How to make a room fade in slowly?
« Reply #7 on: 14 Apr 2013, 17:57 »
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

  • Posts: 195
  • Animating kills me
Re: How to make a room fade in slowly?
« Reply #8 on: 14 Apr 2013, 18:25 »
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 ;)
« Last Edit: 14 Apr 2013, 18:59 by Cerno »
  Currently working on: Sibun - Shadow of the Septemplicon

Khris

  • Posts: 10,676
  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: How to make a room fade in slowly?
« Reply #9 on: 14 Apr 2013, 18:54 »
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: Adventure Game Studio
  1. // after fadein
  2.   FadeOut(64);
  3.   gBlack.Visible = false;
  4.   Wait(1);  // without this, the GUI isn't turned off before the fading!
  5.   FadeIn(1);
  6.  

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

  • Posts: 557
    • I can help with proof reading
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
Re: How to make a room fade in slowly?
« Reply #10 on: 14 Apr 2013, 21:03 »
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

  • Posts: 2,756
  • slasher
    • I can help with AGS tutoring
    • Lifetime Achievement Award Winner
    • I can help with scripting
    • I can help with story design
    • Slasher worked on a game that was nominated for an AGS Award!
Re: How to make a room fade in slowly?
« Reply #11 on: 15 Apr 2013, 18:52 »
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.