Godot - Implement repeat processing with Tween
Code example to implement repeat processing using Tween's set_loops()
in GDScript.
Code example to implement repeat processing with Tween.
Create a new Tween with create_tween()
, and specify repeat processing with set_loops()
.
Specify number of repeats as argument.
var tween = create_tween().set_loops(5)
tween.tween_property(self, "scale", Vector2(5, 5), 1)
tween.play()
To implement infinite loop, specify no argument or "-1".
var tween = create_tween().set_loops(5)
tween.tween_property(self, "scale", Vector2(5, 5), 1)
tween.play()
To express reverse in Tween's repeat processing, it is necessary to create consecutive tween_property()
.
If you have enabled set_parallel()
, use chain()
.
var tween = create_tween().set_loops(5)
tween_property(self, "modulate", Color( 1, 1, 1, 0), 1.0)
tween.tween_property(self, "modulate", Color( 1, 1, 1, 1), 1.0)
tween.play()