Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2020 Graphics & Games

WWDC20 · 24 min · Graphics & Games

Tap into Game Center: Dashboard, Access Point, and Profile

Apple’s social gaming network is ready to play. We’ll walk you through the latest updates to Game Center, starting with its in-game interface and all-new player experience. Learn how to integrate GameKit into your app and authenticate players effectively, and discover the Access Point, which brings players into the in-game dashboard. From there, we’ll explore player profiles and their options for privacy. After exploring Game Center’s interface, Dashboard, and player profiles, continue to the next video to learn about Leaderboards, Achievements, and Multiplayer gaming. And for more about preparing your game’s interface for these new capabilities, see “Design for Game Center.”

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 9 snippets

Presenting the main dashboard swift · at 10:05 ↗
// GKGameCenterViewController

public init(state:)
[...]

// Example: Display Main Dashboard
let vc = GKGameCenterViewController(state: .dashboard)
vc.gameCenterDelegate = self
present(vc, animated: true, completion: nil) 

[...]
enum GKGameCenterViewControllerState : Int {
   case `default`
   case leaderboards
   case achievements
   case challenges
   case localPlayerProfile
   case dashboard
}
Display a specific leaderboard swift · at 10:51 ↗
// Display scores for a specific leaderboard
let vc = GKGameCenterViewController(
                leaderboardID: "grp.xyz.laketahoe",
                playerScope: .global,
                timeScope: .allTime)
vc.gameCenterDelegate = self
present(vc, animated: true, completion: nil)
Configure and show Access Point swift · at 13:18 ↗
// Configure and show Access Point
func showMainMenu() {
    // Call your code to setup the main menu
    self.setupMainMenu()

    // Place access point on top left   
    GKAccessPoint.shared.location = .topLeading    

    // Show highlights
    GKAccessPoint.shared.showHighlights = true
 
    // Show it!
    GKAccessPoint.shared.isActive = true
}
Observing isPresentingGameCenter swift · at 14:00 ↗
let observation = GKAccessPoint.shared.observe(
           \.isPresentingGameCenter
    ) { [weak self] _,_ in
    self.paused = GKAccessPoint.shared.isPresentingGameCenter
}
Changing the frame swift · at 14:44 ↗
// Observable properties
// frameInScreenCoordinates

let observation = GKAccessPoint.shared.observe(
           \.frameInScreenCoordinates
    ) { [weak self] _,_ in
    let screenFrame = GKAccessPoint.shared.frameInScreenCoordinates
    let accessPointFrame = myView.convert(screenFrame, from: nil)
    // adjust your layout
}
Handling focus swift · at 15:18 ↗
// Apple TV and controllers

// track and update focus
func trackController(position: CGPoint) {
  let screenFrame = GKAccessPoint.shared.frameInScreenCoordinates
  let accessFrame = myView.convert(screenFrame, from: nil)
  // if the point is in the access point turn on feedback
  accessPointElement.focusFeedback = CGRectContainsPoint(accessFrame, position)
}
Handling selection swift · at 15:38 ↗
// Apple TV and controllers

// Handle selection
func accessPointSelected() {
  GKAccessPoint.shared.triggerAccessPoint {}
}
Showing the player profile swift · at 20:01 ↗
// Local player profile

let profileVC = GKGameCenterViewController(state: .localPlayerProfile)
profileVC.gameCenterDelegate = self

present(profileVC, animated: true, completion: nil)
Player restrictions swift · at 20:28 ↗
// Local player restrictions

GKLocalPlayer.local.authenticateHandler = { viewController, error in
    let isGameCenterReady = (viewController == nil) && (error == nil)

    if isGameCenterReady {
        if GKLocalPlayer.local.isUnderage {
            // Hide explicit game content
        }

        if GKLocalPlayer.local.isMultiplayerGamingRestricted {
            // Disable multiplayer game features
        } 

        if GKLocalPlayer.local.isPersonalizedCommunicationRestricted {
            // Disable in game communication UI
        }    
    }
}

Resources