Slowly Darken The Scene

Godot Version

v4.2.stable

Question

` I’ve just wanted to slowly darken the screen when the Godot game starts. It occurred to me that I could create a panel for this and darken it slowly, and since it seemed easy, I aimed to create a transparent panel and write code on it, but it doesn’t work. Maybe I can change the code or use another alternative method. I hope you can help me. :face_with_spiral_eyes:

image

You can easily do it by AnimationPlayer. We generally not do this by codes. And it is best to use ColorRect for it instead of Panel.

Why not through the code? I do it with a Tween usually and it works fine.

2 Likes

Because you can do it by AnimationPlayer easily, it’s a simple thing. But you are right, it also can be done by tween

var tween = create_tween()
tween.tween_properly(self, "modulate:a", 0.0, 2.0)
tween.play()
await tween.finished
tween.kill()
1 Like

I guess it’s subjective then, because I find Tweens easier and faster to use than AnimationPlayer.
And you don’t need to manually start and kill the Tween, it’s done automatically. Your code can be simplified to this and will work just as fine :slight_smile:

var tween = create_tween()
tween.tween_properly(self, "modulate:a", 0.0, 2.0)
1 Like