ScreenTransition Duration

Started by beren, Wed 12/12/2007 00:32:56

Previous topic - Next topic

beren

How can I set the duration / length of the standard screen transition inside an AGS game?

I am using the Fade in/out transition method. Even if I was scripting, SetScreenTransition(eTransitionFade); and SetNextScreenTransition(eTransitionFade); don't take any additional arguments.
I have searched the board for ScreenTransition length and duration, but couldn't find anything.
Thank you in advance for your answers. :)

ANSWER (Workaround):

This is my workaround answer as suggested by GarageGothic. I extracted it from my more complex "room intro" code, so in case that it doesn't work for you, feel free to contact me via PM.

General Settings:
Set the standard room transition style to "Instant".

Fadein GUI:
Create a new GUI and name the scriptname "Fade" (will be "gFade" then).
The GUI needs to be black (or whichever color you like) and share your game's screen resolution.

Room Custom Property:
Add a new custom property, that way you can enable or disable the fade for each room:
fadein, boolean, fades from black to room

Global Script:
Code: ags


// Ontop of your global script:
function on_event(EventType event, int data) {
  if (event == eEventLeaveRoom) FadeOut(2); // In case you want to fade out, too. Or you can use the same GUI Workaround to do it.
    if (event == eEventEnterRoomBeforeFadein && GetRoomProperty("fadein") == true){	  
      gFade.Visible = true;
      mouse.Visible = false;
    }
    else{
      gFade.Visible = false;
    }
  }
}

// Fade Room in:
function FadeRoomIn() {
  StartCutscene(eSkipESCOnly); // User can use ESC to skip fade
  int vGuiTrans = 0;
  gFade.Transparency = 0;

  while (vGuiTrans < 100){
    vGuiTrans += 5;    
    gFade.Transparency = vGuiTrans;
    Wait (1);
  }

  gFade.Visible = false;
  mouse.Visible = true; // Only if you want to show the mouse at that time
  EndCutscene();
}



Room Interaction:
Add a new run script action for the rooms you want the fade in to happen. Add it to "Player enters room(after fadein)":
Code: ags


  // script for Room: Player enters room (after fadein)
  FadeRoomIn();

www.beren.net - digital design
www.namator.com - generate names for your characters
www.bio.beren.net - annihilate all life on earth

GarageGothic

#1
I don't think it's possible to adjust the transition speed. However, if you just want fade to/from black, the easiest workaround would be to create a full-screen black GUI and fade in/out by adjusting its transparency in repeatedly_execute_always.

beren

Thank you! However I guess there might be a workaround with FadeIn(); and FadeOut();, but then I would have to add it to the "Player enters room (Before Fadein)" and "player leaves room" interaction in every room :(
www.beren.net - digital design
www.namator.com - generate names for your characters
www.bio.beren.net - annihilate all life on earth

GarageGothic

#3
True (though for fading in, you could put the code in the on_event call for eEventEnterRoomBeforeFadein). I actually find it makes for smoother transition if you actually fade as the player walks off-screen, not after he's left. So you could trigger the code on a region near the exit and move the character off-screen with a blocking walk command while the screen fades.

Edit: I had actually forgotten about the FadeIn/Out commands as they are blocking and you would have to wait for the fade to finish before the character enters the screen. In general, fading is way overused in adventure games, even though it has become genre standard. Try cutting straight between scenes - I personally find it keeps up the pace of the game, especially if you don't have the player walk all the way onto/off-screen every time. In movies fading is generally used to indicate passage of time or travel between distant locations, so for those instances it does have a purpose.

monkey0506

#4
Quote from: beren on Wed 12/12/2007 00:49:27but then I would have to add it to the "Player enters room (Before Fadein)" and "player leaves room" interaction in every room

You could put the following in your global script:

Code: ags
#define FADE_SPEED 32

function on_event(EventType event, int data) {
  if (event == eEventEnterRoomBeforeFadein) FadeIn(FADE_SPEED);
  else if (event == eEventLeaveRoom) FadeOut(FADE_SPEED);
}


Keeping in mind that for FadeIn/FadeOut the speed parameter is 1-64 (slowest to fastest (instant)).

Though GG probably does have a point about fading and whatever else he said. :=

beren

GarageGothic, monkey_05_06, thank you!

I tried to add the code in minor variation to my *global script*, but ran into the following problem I couldn't quite solve:

eEventLeaveRoom works, the screen fades nicely.
eEventEnterRoomBeforeFadein doesn't work, the screen uses the default transition.

I removed all my entries for that room in any room interaction (event), but still the same issue. What am I missing?

The change I did was set the FADE_SPEED to a way lower value, around 2 since everything else fades very quickly on my computer. Strange though. Any idea why that happens?
www.beren.net - digital design
www.namator.com - generate names for your characters
www.bio.beren.net - annihilate all life on earth

Ashen

This might be an obvious question, but I don't see it mentioned anywhere: Have you disabled the default fade transitions? (SetScreenTransition(eTransitionInstant), or from general settings.)
It could be that the default fade and the FadeIn command don't play well togther...

(And I've noticed that anything above 2 is still a very quick fade, too.)
I know what you're thinking ... Don't think that.

beren

Ashen, yes I did use "instant" as the default transition, but it didn't help. I also tried "fade". Changed those in the "General Settings".
www.beren.net - digital design
www.namator.com - generate names for your characters
www.bio.beren.net - annihilate all life on earth

monkey0506

Quote from: Ashen on Wed 12/12/2007 11:33:39(And I've noticed that anything above 2 is still a very quick fade, too.)

I haven't actually played around with the FadeIn/Out functions much to see how the speed parameter actually affects the speed of the fading. The manual says that '1' is the slowest fade speed, and 64 would be instant, so I presumed 32 would be a moderate-fast fade, not "very quick". Guess that's what happens when you don't test these things. ;)

As for the 'eEventEnterRoomBeforeFadein' not working properly...perhaps its possible that this EVENT isn't working properly with the instant transition style?

beren

#9
The FadeIn and FadeOut speed parameters should be given in game ticks.
Yes, seems like the eEventEnterRoomBeforeFadein ignores the Gloabl script's event handler.
www.beren.net - digital design
www.namator.com - generate names for your characters
www.bio.beren.net - annihilate all life on earth

beren

#10
Would it be wise to submit the issue as bug? I still have a feeling I'm missing something, but I can't figure out what :/
Even tried a workaround with a function that always fades in, but it only works "after fadein", hence there's a "blinking effect" when the the function is called, fading in *after* the room was already visible for a brief moment.
www.beren.net - digital design
www.namator.com - generate names for your characters
www.bio.beren.net - annihilate all life on earth

GarageGothic

Well, it seems obvious that you can't FadeIn before the room has actually "faded in" since there would be no background to fade to. However, if you use my suggested workaround of a fading black GUI, you could certainly call this custom FadeIn function from eEnterRoomBeforeFadeIn (since the function would only change a variable, and the actual fading would be handled in Repeatedly_Execute_Always once the room is loaded).

I do agree it's weird we don't have a eEnterRoomAfterFadeIn event though.

beren

#12
D'oh!
I forgot I wanted to try that! Awesome, thanks I'll do that asap and give feedback :)

EDIT: Works now, added the solution to my original post. Thanks a lot! :)
www.beren.net - digital design
www.namator.com - generate names for your characters
www.bio.beren.net - annihilate all life on earth

SMF spam blocked by CleanTalk