Wiring up GameScene for game over

We need to tell the HUD class to show the restart and main menu buttons once the player runs out of health. Open GameScene.swift and add a new function to the GameScene class named gameOver, as shown here:

func gameOver() { 
    // Show the restart and main menu buttons: 
    hud.showButtons() 
} 

That is all for now; we will add to the gameOver function in the next chapter, when we implement a high score system.

Get Swift Game Development - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.