Fade to Black function

  • #1, by marvelSaturday, 29. April 2017, 00:23 7 years ago
    Hey guys,
    I want to make a simple fade to black, including a small delay of 1 or 2 seconds.

    Originally I would use a "change scene" action part for that and show a black screen. But this is pretty complicated, especially if you have looping background sounds (that would just stop if you change the scene). 

    Could anybody help me with a simple "fade to black" function? I think there are many guys here who would need a function like that. smile

    Thanks in advance smile

    Marvel

    Key Killer

    598 Posts


  • #2, by sebastianSaturday, 29. April 2017, 00:35 7 years ago
    with a little bit of Lua you could do the following inside an execute a script action part:

    game.CurrentScene:to(1500, {SceneBrightness = 0}) 

    its also possible to pass an easing effect as a third argument. 

    Thread Captain

    2346 Posts

  • #3, by marvelSaturday, 29. April 2017, 01:03 7 years ago
    Thats great. Thank you Sebastian. grin

    But one thing is weird: First, the room gets dark. After the room change, the next room (a close up) is not dark. And when I get back and leave the close up, the very next room is dark again... 

    Are menus and rooms show a different behavior here?

    Key Killer

    598 Posts

  • #4, by afrlmeSaturday, 29. April 2017, 03:04 7 years ago
    It's because the script Sebastian shared is adjusting the brightness for that particular scene only. Just add the same script inside of an at begin of scene action for that scene but set the delay to 0 & brightness to 100.
    game.CurrentScene:to(0, {SceneBrightness = 100})

    Imperator

    7278 Posts

  • #5, by sebastianSaturday, 29. April 2017, 14:55 7 years ago
    ah yeah, sorry. So to make this complete:

    on scene enter action:

    game.CurrentScene:to(0, {SceneBrightness = 0})
    game.CurrentScene:to(1500, {SceneBrightness = 100})

    on scene leave action (actually i would do this before the leave action triggers)

    game.CurrentScene:to(1500, {SceneBrightness = 0})


    Thread Captain

    2346 Posts

  • #6, by marvelSaturday, 29. April 2017, 19:53 7 years ago
    Well, basically it works... but the brightness-fade doesn't have any effect on the particles. ^^ Any idea how to fix this?

    Key Killer

    598 Posts

  • #7, by afrlmeSaturday, 29. April 2017, 20:09 7 years ago
    Well, basically it works... but the brightness-fade doesn't have any effect on the particles. ^^ Any idea how to fix this?
    It's the scene brightness value. Guess you will probably have to adjust the actual game brightness instead, but I was having trouble with window brightness as it wasn't fading to 0 correctly when I tried to create a global brightness slide in an options menu scene.

    Imperator

    7278 Posts

  • #8, by sebastianSaturday, 29. April 2017, 20:15 7 years ago
    The normal fade effect of VS is not working ? You can set the fade delay in the game options and thats what is used at scene switching, too i guess...

    (maybe its possible to edit the duration via lua)

    Thread Captain

    2346 Posts

  • #9, by afrlmeSaturday, 29. April 2017, 20:32 7 years ago
    Yeah according to data structure you can edit the global fade delay of the scene fade transition with...
    game.FadeDelay = 500

    As for what I was talking about in my last post, was this. For some reason when I tried using that in combination with a slider script I wrote it kept getting stuck at about 20% or something. Wouldn't let me slide it all the way to 0% which is strange as it was same script/functions I was using for the volume sliders which were working as they should.

    Imperator

    7278 Posts

  • #10, by marvelSaturday, 29. April 2017, 21:42 7 years ago
    Unfortunately I cannot use the general fade effect.

    Let me explain:
    I want to show a close up and need an inventory in that closeup. Therefore I also need a person on the screen (and a waysystem with a single way point). I solve this by changing the outfit to invisible and then change the screen.

    The problem now is, that there will be a short flickering of the persons sprite, when the outfit will be set to invisible. Thats why I fade to black BEFORE I change the outfit. 

    I solved this problem with your script. But as the fade doesn't affect the particles, I have a new problem now. ^^


    Key Killer

    598 Posts

  • #11, by sebastianSaturday, 29. April 2017, 21:49 7 years ago
    Are the particles bound to an object?

    You could make an object with a screen filling black image in front of all objects which you could fade in by changing its visibility...

    Thread Captain

    2346 Posts