Highlight
Game Center in 2020 adds recurring leaderboards, new leaderboards and achievement pages, achievement progress reporting processes, multiplayer matchmaking UI options, and personalizedCommunicationRestricted restriction flags, allowing games to connect recurring competitions, achievement collection, and real-time or turn-based matching to GameKit.
Core Content
Many games only require a high score list at the beginning. When there are more players, problems arise: the permanent rankings are occupied by early masters, making it difficult for new players to catch up; weekly activities require separate rankings, and developers also have to deal with time windows; achievement progress is scattered in the game UI, and players do not know what to do next; multi-person invitations also need to take care of friends, people who have played recently, contacts, and automatic matching.
WWDC 2020’s Game Center incorporates these common game services into GameKit. The leaderboard has added recurring leaderboards, which can create occurrences (single cycles) on an hourly, daily or weekly basis. The in-game UI of Game Center has also been redesigned, and rankings, achievements, and multiplayer matches can all be hosted on the system page.
The value of this change is straightforward. Developers don’t have to maintain the entire UI for weekly competition tables, achievement pages, and invitation lobbies themselves. The game only needs to submit scores, report achievements, and create matching requests at the right time, and then let Game Center take care of display, matching, and part of the network process.
Session is divided into three sections. The first paragraph talks about the leaderboard, focusing on the difference between classic leaderboard and recurring leaderboard. The second paragraph talks about achievements, focusing on the four display states, quantity limits andGKAchievementReport. The third section talks about multiplayer games, focusing on the three modes of real-time, turn-based, and server-hosted, as well as the new matching UI configuration and privacy restriction flags added to iOS 14.
Detailed Content
Periodic Leaderboards: Hand over limited-time competitions to Game Center
(01:23) Past Game Center leaderboards have been classic leaderboards. They permanently retain player scores and rankings, and are suitable for recording total experience, the highest score in history, and the shortest time on a level. New for 2020 are recurring leaderboards for short, recurring competitions such as hourly 15-minute challenges, one-hour events every Sunday at noon, and a new leaderboard round every day.
(02:32) Periodic rankings are configured in App Store Connect. Developers set the initial start date, frequency, and duration. Each occurrence has a start and end time, and a new occurrence will only start after the current occurrence ends. duration cannot be greater than frequency because occurrences cannot overlap.
(04:05) When submitting classic leaderboard scores, useGKLeaderboard.submitScore. The same call can submit scores to one or more leaderboard IDs.
// Use the class method to submit score to one or more leaderboards at once
GKLeaderboard.submitScore(self.points, context: 0, player: GKLocalPlayer.local,
leaderboardIDs: ["my.leaderboard.id"]) { error in
}
Key points:
self.pointsis the score to be submitted this time. -context: 0is an optional contextual value that Game Center will save with the score. -player: GKLocalPlayer.localIndicates currently authenticated local players. -leaderboardIDsMultiple ranking IDs can be placed, which is suitable for writing multiple rankings in one settlement.- Handle submission errors in completion handler.
(04:30) For recurring leaderboard, you can also submit scores directly to the periodic leaderboard ID. Game Center will post the score to the current active occurrence. Game Center delays sending if the device is offline; the server validates by the time the score is received, so offline submissions may fail after the occurrence expires.
// Use the class method to submit score to one or more leaderboards at once
GKLeaderboard.submitScore(self.points, context: 0, player: GKLocalPlayer.local,
leaderboardIDs: ["my.recurring.leaderboard.id"]) { error in
}
Key points:
- The code form is the same as classic leaderboard.
-
"my.recurring.leaderboard.id"Points to the periodic ranking list configured in App Store Connect. - Submissions can only fall into the current active occurrence.
- For offline scenarios, error handling must be reserved in the game settlement experience.
(04:48) If the game has already loaded an occurrence, you can also passGKLeaderboardInstance submission. Session is recommendedstartDateanddurationDetermine whether the occurrence is still active.
// Submitting to a specific occurrence of a recurring leaderboard
GKLeaderboard.loadLeaderboards(IDs:["my.recurring.leaderboard.id"]) { (fetchedLBs, error) in
if let lb = fetchedLBs?.first {
lb.submitScore(self.points, context: 0, player: GKLocalPlayer.local) { error in
}
}
}
Key points:
loadLeaderboardsFirst load the leaderboard by ID. -fetchedLBs?.firstGet the corresponding occurrence of the current occurrenceGKLeaderboard。lb.submitScoreSubmit the score to this occurrence.- This way of writing is suitable for scenarios where the custom UI already holds occurrence objects.
Ranking UI: System page and custom page have separate entrances
(05:25) There are two ways to display the rankings. Apple recommends using GameKit’s in-game UI becauseGKGameCenterViewControllerWill handle lists, leaderboard details, friends and global scope, time range of classic leaderboard, occurrence switching of recurring leaderboard.
// Launching in-game UI
// Display a list of leaderboards
let vc = GKGameCenterViewController(
state: .leaderboards)
vc.gameCenterDelegate = self
present(vc, animated: true, completion: nil)
// Or directly display scores for a specific leaderboard
let vc = GKGameCenterViewController(
leaderboardID: "YOUR_ASC_LEADERBOARD_ID",
playerScope: .global,
timeScope: .allTime)
vc.gameCenterDelegate = self
present(vc, animated: true, completion: nil)
Key points:
state: .leaderboardsOpen the leaderboard list. -gameCenterDelegateUsed to receive Game Center page events such as closing.- The second initializer can deep link to the score page of a certain ranking list.
-
playerScope: .globalShows the global scope, or can be switched by the scope supported by GameKit. -timeScope: .allTimeTime dimension for classic leaderboard.
(07:14) If the game wants to draw its own leaderboard UI, it must load the leaderboard and score itself. Recurring leaderboard also handles occurrence. Game Center only retains expired occurrences for up to 30 days; logged in players can usually see the current occurrence and one previous occurrence.
// Accessing previous occurrence
// Load current occurrence of a recurring leaderboard
GKLeaderboard.loadLeaderboards(IDs:["my.recurring.leaderboard.id"]) { (fetchedLBs, error) in
if let current = fetchedLBs?.first {
// Load previous occurrence using the current occurrence
current.loadPreviousOccurrence { (prevOccurrence, error) in
// Do something with the previous occurrence
}
}
}
Key points:
loadLeaderboardsThe current occurrence is loaded by default for recurring leaderboards. -current.loadPreviousOccurrenceGets the previous accessible occurrence through the current occurrence. -prevOccurrenceCan be used to display results from the previous round or review after the game.- When the game draws its own UI, it is necessary to consider the situation where the occurrence is cleared or the player did not participate in the previous round.
Achievements: Use progress to drive players back to the game
(10:20) Achievement is a collectible item after the player achieves the goal. Game Center achievements have four presentation states: locked, in-progress, completed, and hidden. hidden is suitable for achievements that don’t want to spoil the plot or objectives in advance. The Game Center Dashboard for iOS, macOS, and tvOS all display achievements, so achievement text, images, and progress need to independently illustrate player goals.
(13:01) The quantity limit is also very clear: a game has a maximum of 100 achievements, each with a maximum of 100 points, and a total of up to 1000 points. Don’t use up your budget when the first version is launched, as new achievements may be needed for subsequent updates.
(14:34) Integration achievements are divided into three steps: first authenticate local players;GKAchievementReport progress; finally use Game Center Dashboard or achievement page to display. As long as the progress of an achievement in GameKit is still 0, it will appear in the locked state.
if let achievement = GKAchievement(identifier: identifier) {
achievement.percentComplete = percentComplete
GKAchievement.report([achievement]) { error in
if let error = error {
print("Error in reporting achievements: \(error)")
}
}
}
Key points:
identifierMust correspond to the achievement ID configured in App Store Connect. -percentCompleteIndicates the completion progress. When reaching 100, the achievement is completed. -GKAchievement.reportOne array can be reported at a time.- The completion handler needs to handle reported failures, especially network or authentication issues.
(16:05) Prioritize use when displaying achievementsGKGameCenterViewController(state: .achievements). If you draw your own achievement page, then useGKAchievementDescriptionRead localized title, incomplete description, completed description, and completed and incomplete images.
// Showing the Game Center achievements page
let viewController = GKGameCenterViewController(state: .achievements)
viewController.gameCenterDelegate = self
present(viewController, animated: true)
Key points:
state: .achievementsDirectly open the achievements page of the current game. -gameCenterDelegateResponsible for page life cycle callbacks. -presentAllow players to check progress within the game without leaving the game.- When drawing your own UI, text localization should still come from data returned by GameKit.
Multiplayer: Matchmaking, Invitations, and Privacy Restrictions
(19:22) Game Center supports three types of multiplayer games. Real-time mode is responsible for finding players, establishing connections, and sending data. Turn-based mode is responsible for turn management and data storage. Server-hosted mode hands the player list to the developer’s own server.
(21:23) The basic process of real-time multiplayer matching is: authenticate players, createGKMatchRequest, set the number of players and inviteable objects, and then select automatic matching or displayGKMatchmakerViewController. The application should also start withGKInviteEventListener, and register with local players to receive invitations from other players.
Key points:
GKMatchRequestDescribe how many players a game requires.- Session explicitly mentions that the developer sets the number of players in the request and can define who to invite.
-
GKMatchmakerThe automatic matching process will look for other players, and the returned match object is used to send data between players. - If players need to choose their own players, they can display it
GKMatchmakerViewController。 GKInviteEventListenerIt is suitable to register when the app is launched to receive invitations from other players.
(22:52) The turn-based matching process is close to real-time matching. The difference lies in the adoptionGKTurnBasedEventListener, and useGKTurnBasedMatchorGKTurnBasedMatchmakerViewController. Turn-based games do not need to wait for all players to be online at the same time. After creation, the current player can start his or her turn immediately.
Key points:
GKMatchRequestStill describes the number of players and matchmaking conditions. -GKTurnBasedEventListenerResponsible for receiving turn-based events. -GKTurnBasedMatchfor programmatic matching,GKTurnBasedMatchmakerViewControllerUsed to display the system matching interface.- The current player can act first and wait for other players to join or respond later.
(23:29) iOS 14 adds configuration options for matchmaking UI. automatch only is suitable for games that want players to start quickly and randomly. nearby only suitable for ARKit games in the same room. Session also mentioned that the new restrictions will affect both multi-person invitation custom messages and voice chat.
// Check if personalized communication is restricted
if GKLocalPlayer.local.personalizedCommunicationRestricted {
// Disable UI for Voice chat
}
Key points:
GKLocalPlayer.localRepresents the current Game Center player. -personalizedCommunicationRestrictedfortrue, the application should close the relevant personalized communication portal.- The example given by Session is to disable the voice chat UI.
- This check should be put together with the display logic of the multiplayer lobby, invitation entrance, and voice button.
Core Takeaways
-
Make a weekly challenge list: Receive the level scores to the recurring leaderboard and automatically open new occurrences every week. It’s worth doing because new players have a chance to chase rankings every week. You can start by configuring weekly frequency and duration in App Store Connect, and then use
GKLeaderboard.submitScoreSubmit on the level checkout page. -
Enter the limited-time event: Display the countdown to the next round of challenges in the main menu, and display the ranking of the current occurrence during the event. It’s worth doing because the Session explicitly states that the occurrence has start time, duration and next start information. You can load the recurring leaderboard first, and then determine the button status based on the occurrence time.
-
Make a staged achievement route: Design achievements for novices, skilled players and core players respectively. It’s worth doing because the Game Center Dashboard will display the locked, in-progress, and completed status directly to the player. available
GKAchievement(identifier:)andpercentCompleteReport every time task progress changes. -
Create one-click achievement page: Place an “Achievements” button on the pause menu or level settlement page to directly open the Game Center achievements page. It’s worth doing because the system page already handles progress, pictures, and localized display. available
GKGameCenterViewController(state: .achievements)Get started. -
Make a quick multiplayer start: Provide automatch only for casual mode and nearby only for local same-screen or AR gameplay. It’s worth doing because the matchmaking UI reduces the number of steps players need to take when selecting players. available
GKMatchRequestDefine the number of players and choose automatic matching orGKMatchmakerViewController。
Related Sessions
- Tap into Game Center: Dashboard, Access Point, and Profile — First complete the local player authentication, Access Point, Dashboard and player profile entry, and then access the rankings and achievements of this article.
- Design for Game Center — From an interface design perspective, achievement cards, ranking images, multiplayer lobby entrances and Game Center have a unified style.
- Advancements in Game Controllers — After the game service layer is connected to Game Center, the input layer can continue to adapt to handles, haptic feedback and custom mapping.
- Bring keyboard and mouse gaming to iPad — Complements keyboard, mouse, and trackpad input for iPad gaming, suitable for planning with multiplayer and leaderboard experiences.
Comments
GitHub Issues · utterances