Overview
TransitionBlocks is a CanvasLayer-based autoload that provides smooth scene transitions using a spiral block animation. Blocks appear in a spiral pattern from the edge to center, creating a stylish wipe effect.
Access via the global singleton: TransitionBlocks
Signals
Emitted when the fade-out animation completes after a scene change. Used by scenes to trigger UI fade-ins or other post-load logic.
Exported Properties
Size of each transition block in pixels
Color of the transition blocks
Methods
wipe_to()
Triggers a block wipe transition and changes to the target scene.Godot resource path to the target scene (e.g.,
"res://scenes/main_menu.tscn")Duration of each block’s fade-in animation in seconds
No return value
- Shows the transition layer
- Blocks fade in one-by-one following a spiral pattern
- After all blocks are visible, changes scene
- Calls
wipe_out_fade()to fade out blocks - Emits
transition_finishedsignal
wipe_out_fade()
Fades out the block grid with a smooth overlay. Called automatically bywipe_to().
Duration of fade-out animation in seconds
No return value
- Creates a black ColorRect overlay
- Fades overlay from transparent to opaque
- Hides all blocks
- Fades overlay back to transparent
- Removes overlay
- Emits
transition_finishedsignal
Internal Methods
create_blocks()
Generates ColorRect blocks to cover the entire viewport. Called automatically in_ready().
Implementation:
- Calculates grid dimensions based on viewport size and block_size
- Creates enough blocks to fully cover the screen
- All blocks start invisible
calc_spiral_order()
Calculates the spiral traversal order for block animations. Called automatically in_ready().
Implementation:
- Uses a directional spiral algorithm (right → down → left → up)
- Stores block indices in
block_orderarray - Creates the signature edge-to-center animation pattern
Animation Timing
Block Reveal Phase
- Grid size: 17 cols × 30 rows = 510 blocks
- Delay phase: 510 × 0.004s = 2.04s
- Total reveal time: ~2.14s (with default duration=0.1)
Fade-Out Phase
Complete Example
Usage in Minigames
All minigames use TransitionBlocks to return to the main menu: Turtle Runner:Architecture Notes
- Autoload: TransitionBlocks is a global singleton accessible from any scene
- CanvasLayer: Renders above all game content (high z-index)
- Tweens: Uses Godot’s Tween system for smooth animations
- Non-blocking: Scene change happens asynchronously via
get_tree().create_timer() - Reusable: Blocks are created once and reused for all transitions