Menu
CoddyTech

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 icon

Challenge

Medium

Walk into a coin. Make it pop before it goes:

  1. grow its scale to Vector2(1.8, 1.8) in 0.25 seconds,
  2. fade "modulate:a" to 0.0 at the same time,
  3. 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()
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Game Feel

Practice on your own: Godot playground