A Coin That Pops
Part of the Game Feel section of Coddy's Godot journey. Lesson 7 of 23.
When you touch a coin, it disappears at once. A short pop shows the player they picked it up. The coin grows and fades, then it is removed.
The pop is a tween with two steps that run together. The coin must stay until the tween is done. A tween sends the finished signal when its last step ends, and await waits for it.
var tween = create_tween()
tween.tween_property(self, "scale", Vector2(2, 2), 0.3)
tween.parallel().tween_property(self, "modulate:a", 0.0, 0.3)
await tween.finished
queue_free()await tween.finished pauses the function until the tween ends. Then queue_free() runs. The rest of the game keeps running while it waits.
Challenge
MediumWalk into a coin. Make it pop before it goes:
- grow its
scaletoVector2(1.8, 1.8)in 0.25 seconds, - fade
"modulate:a"to0.0at the same time, - wait for the tween to finish, then
queue_free().
Try it yourself
extends Area2D
func _ready():
body_entered.connect(_on_body_entered)
func _on_body_entered(body):
queue_free()
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Game Feel
1Tweens
Your First TweenTween Any PropertyFade OutEase OutOne After AnotherAt the Same TimeA Coin That PopsPractice on your own: Godot playground