+1 vote

I want to do such a thing. After selecting in the main menu, the screen gradually dims, then loaded another scene, the screen is gradually lightened. How is this implemented?

in Engine by (355 points)

2 Answers

+2 votes
Best answer

The simplest way would be to put a dark texture on top of your scene (with the highest Z), make it visible and with opacity 0 at first, and gradually increase its opacity in _process.

Then change the scene, and do the same the other way around (full opacity -> opacity 0).

by (1,903 points)
selected by

AFAIK the highest Z is what is shown on top, not the lowest.

Right, fixed :)

Why not doing it with a polygon node? You don't need a texture and it saves texture lookups in the shader.
Also, a CanvasModulate node could work too and involves less overdraw :p
I do that in my game with an AnimationPlayer so I don't even have to script it.

Don't hesitate to post your suggestion as an answer instead of a comment. This is the purpose of a Q&A: everyone proposes their answer and the OP can select the most fitting one. Here I just gave a quick and dirty solution, if you have a better one we'll all be happy to read it and maybe learn from it :)

Sorry sometimes I put things in comments that could be an answer, and I forget to use Answer. I posted it then :)

I have finally done it. Thanks, I took your advice.

+1 vote

You can also do it with a polygon node, you don't need a texture and it saves texture lookups in the shader.
Also, a CanvasModulate node could work too and involves less overdraw :p
I do that in my game with an AnimationPlayer so I don't even have to script it.

by (27,958 points)

Node that currently Polygon2D opacity does not work.

Gaaah yes Polygon transparency doesn't works in 2.1... a little shader tinkering and it should work I guess.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.