Menu
CoddyTech

Process Mode

Part of the Game Rules section of Coddy's Godot journey. Lesson 14 of 29.

A paused game stops every node. Some nodes should keep running, like a blinking Game Over message or a pause menu.

A node's process_mode decides:

  • Node.PROCESS_MODE_INHERIT: do what the parent does. This is the default.
  • Node.PROCESS_MODE_PAUSABLE: stop when the game is paused.
  • Node.PROCESS_MODE_ALWAYS: keep running, paused or not.
$Music.process_mode = Node.PROCESS_MODE_ALWAYS

The script now blinks Game Over with a Timer called Blink. The pause stops that timer, so the message never blinks.

challenge icon

Challenge

Easy

Keep Game Over blinking while the game is paused.

  1. In _ready(), take the Blink timer.
  2. Set its process_mode to Node.PROCESS_MODE_ALWAYS.

Press Play and lose three lives: Game Over blinks over the frozen game. Then Check.

Try it yourself

extends Node2D

var lives = 3

func _ready():
	$HUD/Lives.text = "Lives: %d" % lives
	$Player.hurt.connect(_on_player_hurt)
	$Blink.timeout.connect(_on_blink_timeout)

func _on_player_hurt():
	lives -= 1
	$HUD/Lives.text = "Lives: %d" % lives
	if lives == 0:
		$HUD/GameOver.visible = true
		get_tree().paused = true

func _on_blink_timeout():
	if lives == 0:
		$HUD/GameOver.visible = not $HUD/GameOver.visible

All lessons in Game Rules

Practice on your own: Godot playground