Godot - Implementing Fade-In and Fade-Out with Tween
Code example to implement fade in and fade out using Tween in GDScript.
It is possible to implement fade in and fade out using Tween.
Create a new Tween with create_tween()
, and create a modulate change animation with tween_property()
.
If fading the entire game screen in or out, create the Tween on the root node.
If fading only specific objects in or out, create the Tween on the target nodes.
# tween_property( target node, "modulate", Color( 1, 1, 1, transparency), duration)
# Fade in
var tween = create_tween()
tween.tween_property(self, "modulate", Color( 1, 1, 1, 1), 1.0)
tween.play()
# Fade out
var tween = create_tween()
tween.tween_property(self, "modulate", Color( 1, 1, 1, 0), 1.0)
tween.play()
TitleGodot - Implementing Fade-In and Fade-Out with Tween
CategoryGodot
Created
Update
AuthorYousuke.U