遊戲進度存檔
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
遊戲進度存檔服務可以讓您在 Google 伺服器儲存玩家的遊戲進度,非常便利。遊戲可以擷取遊戲進度存檔資料,讓玩家用任何裝置重新開啟遊戲後能從上次的儲存點繼續進行遊戲。
遊戲進度存檔服務可以跨多個裝置同步處理玩家的遊戲資料。舉例來說,如果您有在 Android 執行的遊戲,就能利用遊戲進度存檔服務讓玩家在 Android 手機上開始遊戲,之後再用平板電腦繼續進行遊戲,而不會損失任何遊戲進度。利用這個服務,也能確保玩家即使在遺失裝置、裝置損毀,或是換購更新型號之後,仍然可以接續遊戲進度。
如果想瞭解如何為您使用的平台實作遊戲進度存檔,請參閱「用戶端實作」。
遊戲進度存檔基礎知識
遊戲進度存檔由兩個部分組成:
- 非結構化的二進位檔 blob - 這個資料可以代表任選內容,您的遊戲須負責剖析及寫入。
- 結構化的中繼資料 - 和此二進位檔資料相關聯的其他屬性,可讓 Google Play 遊戲服務在預設遊戲進度存檔清單使用者介面 (UI) 中以視覺方式呈現遊戲進度存檔,並可在 Google Play 遊戲應用程式中呈現實用的資訊 (例如上次更新的時間戳記)。
只要遵守使用者配額,每一位玩家的遊戲都可以寫入任意數量的遊戲進度存檔,因此並未強制規定玩家只能擁有一組存檔。
封面圖片
除了保持進度的功能之外,遊戲進度存檔服務也能在視覺上提供使用者體驗。我們強烈建議您為存檔準備相對應的代表圖片,並為兩者建立關聯。如果您的遊戲使用 Play 遊戲 SDK 提供的預設遊戲進度存檔清單使用者介面 (UI),則此 UI 會顯示封面圖片。Google Play 遊戲應用程式也可能會顯示這些封面圖片。
說明
您可以提供簡短的文字,藉此說明特定遊戲進度存檔的內容。玩家可以直接看到這段說明,而說明內容應該要能概略說明這個遊戲進度存檔所代表的狀態,例如「在黑暗森林和哥布林戰鬥」。
配額
開發人員不需為雲端儲存的遊戲進度存檔資料付費。這些資料都會按照玩家的 Google 雲端硬碟配額計算,您不需擔心這個問題。遊戲開發人員只要注意 Google Drive API 配額即可。
讀取/寫入隔離
所有遊戲進度存檔都會儲存在玩家的 Google 雲端硬碟的應用程式資料資料夾內。只有您的遊戲才能讀取並寫入這個資料夾,其他開發人員推出的遊戲無法檢視或修改內容,讓資料更安全、更不容易損毀。另外,系統會防止玩家直接竄改遊戲進度存檔,避免玩家修改特定的遊戲進度存檔。
支援離線使用
就算玩家裝置處於離線狀態,遊戲依然可以讀取並寫入遊戲進度存檔,不過在建立網路連線之前無法和 Google Play 遊戲服務保持同步。重新連線之後,Google Play 遊戲服務就能以非同步方式更新 Google 伺服器上的遊戲進度存檔資料。
衝突解決
當遊戲使用遊戲進度存檔服務時,可能會在嘗試儲存資料時發生衝突。如果有使用者透過不同裝置或電腦執行多個應用程式執行個體,就有可能發生這種衝突。您的應用程式必須有可以解決這種衝突的能力,以便提供最佳使用者體驗。
會發生資料衝突,通常是因為應用程式執行個體在嘗試要載入或儲存資料時無法取得遊戲進度存檔服務。一般而言,避免發生資料衝突最合適的方式是一律在應用程式啟動或恢復執行的時候載入服務上的最新資料,並按照合理的頻率把資料儲存到服務上。不過,有時依然無法避免資料衝突。應用程式應該要能盡力解決衝突問題,藉此保存使用者資料,並提供良好的使用體驗。
限制
Google Play 遊戲服務目前強制規定二進位檔資料和封面圖片的大小,分別為 3 MB 和 800 KB。
遊戲進度存檔的結構化中繼資料含有以下屬性:
資源 |
說明 |
ID |
Google Play 遊戲服務為此遊戲進度存檔產生的專用字串。您可以在遊戲用戶端用這組 ID 參照遊戲進度存檔。 |
名稱 |
開發人員為遊戲進度存檔取的簡短名稱,例如「Save slot 1」或「PlayerName_Save1」。玩家不會看到這個內容。 |
說明 |
開發人員提供的遊戲進度存檔說明。 |
上次修改時間 |
Google Play 遊戲服務針對上次遊戲進度存檔更新時間而產生的時間戳記,以毫秒為單位。 |
遊戲進行時間 |
開發人員在遊戲進度存檔上顯示的時間 (以毫秒為單位)。這個值應該代表玩家遊玩相應遊戲進度存檔的時間。舉例來說,如果遊戲進行時間值為 3600000,Google Play 遊戲服務便會顯示「1 小時」。 |
封面圖片 |
這是由開發人員提供的非必要屬性,內含封面圖片的資訊。 |
用戶端實作
如果想瞭解如何為您的平台實作遊戲進度存檔,請參閱以下資源:
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[],[],null,["# Saved games\n\nThe Saved Games service gives you a convenient way to save\nyour players' game progression to Google's servers. Your game can retrieve the\nsaved game data to allow returning players to continue a game at their last\nsave point from any device. \n\nThe Saved Games service makes it possible to synchronize a player's game data\nacross multiple devices. For example, if you have a game that\nruns on Android, you can use the Saved Games service to\nallow a player to start a game on their Android phone, and then\ncontinue playing on a tablet without losing any of their progress. This service\ncan also be used to ensure that a player's game play\ncontinues from where it left off even if their device is lost, destroyed, or\ntraded in for a newer model.\n| **Note:** Before using the Saved Games service, you must first [enable it in Google Play Console](/games/pgs/console/enable-features#enabling_saved_games).\n\nTo learn how to implement saved games for your platform, see\n[Client implementations](#client_implementations).\n\nSaved Games basics\n------------------\n\nA saved game consists of two parts:\n\n- An unstructured binary blob - this data can represent whatever you choose, and your game is responsible for parsing and writing to it.\n- Structured metadata - additional [properties](#saved_game_metadata) associated with the binary data that allow Google Play Games Services to visually present Saved Games in the default Saved Games list user interface (UI), and to present useful information in the [Google Play Games app](//play.google.com/store/apps/details?id=com.google.android.play.games) (for example, last updated timestamp).\n\nA game can write an arbitrary number of Saved Games for a single player,\nsubject to [user quota](#quota), so there is no hard requirement to restrict\nplayers to a single save file.\n\n### Cover images\n\nThe Saved Games service provides a visual user experience in addition to\npersistence features. You are strongly encouraged to associate representative\nimages with corresponding save files. If you are using the default Saved Games\nlist user interface (UI) provided by the Play Games SDK in your game,\nthe UI will display these cover images. The cover images may also appear in the\n[Google Play Games app](//play.google.com/store/apps/details?id=com.google.android.play.games).\n\n### Descriptions\n\nYou can provide a short text description of the content of a particular saved\ngame. This description is directly displayed to players and should summarize\nthe state that the saved game represents; for example, \"Fighting the Goblins\nin the Dark Woods\".\n\n### Quota\n\nDevelopers are not charged for any saved game data that's stored in the cloud.\nInstead, this data is counted against the player's Google Drive quota - you\nnever have to worry about it. The only quota that game developers need to care\nabout is their Google Drive API quota.\n\n### Read/Write isolation\n\nAll Saved Games are stored in your players' Google Drive Application Data\nFolder. This folder can only be read and written by your game - it cannot be\nviewed or modified by other developers' games, so there is additional protection\nagainst data corruption. In addition, Saved Games are insulated from direct\ntampering by players so they cannot modify individual Saved Games.\n\n### Offline support\n\nYour game can still read and write to a saved game when the player's device is\noffline, but will not be able to sync with Google Play Games Services until\nnetwork connectivity is established. Once reconnected, Google Play Games Services\nasynchronously updates the saved game data on Google's servers.\n\n### Conflict resolution\n\nWhen using the Saved Games service, your game may encounter conflicts when\nattempting to save data. These conflicts can occur when a user is running more\nthan one instance of your application on different devices or computers. Your\napplication must be able to resolve these conflicts in a way that provides the\nbest user experience.\n\nTypically, data conflicts occur when an instance of your application is unable\nto reach the Saved Games service while attempting to load data or save it. In\ngeneral, the best way to avoid data conflicts is to always load the latest data\nfrom the service when your application starts up or resumes, and save data to\nthe service with reasonable frequency. However, it is not always possible to\navoid data conflicts. Your application should make every effort to handle\nconflicts such that your users' data is preserved and that they have a good\nexperience.\n\n### Limits\n\nGoogle Play Games Services currently enforce size limits on binary data and cover\nimage sizes of 3 MB and 800 KB respectively.\n\n### Saved game metadata\n\nThe structured metadata for a saved game contains these these properties:\n\n| Property | Description |\n|-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **ID** | A unique string generated by Google Play Games Services for this saved game. Use this ID to refer to the saved game in your game clients. |\n| **Name** | A developer-supplied short name for the saved game, for example \"Save slot 1\" or \"PlayerName_Save1\". This is not shown to players. |\n| **Description** | A developer-supplied description of the saved game. |\n| **Last modified** | Timestamp in milliseconds generated by Google Play Games Services for when the saved game was last updated. |\n| **Played time** | A developer-supplied time (in milliseconds) to display on the saved game. This value should represent how long the player has played the corresponding save game. For example, a played time value of 3600000 will be displayed by Google Play Games Services as \"1 hr\". |\n| **Cover image** | This is an optional, developer-supplied property that contains information about the [cover image](/games/pgs/savedgames#cover_images). |\n\nClient implementations\n----------------------\n\nTo learn how to implement Saved Games for your platform, see the following\nresources:\n\n- [Android](/games/pgs/android/saved-games)\n- [Checklist for implementing saved games](/games/pgs/quality#saved-games)"]]