+31 (0) 35 646 63 00 info@spilgames.com

Working with Game States

The Spil Games SDK supports the saving of game state information. There are two varieties of game state information:

  • Private: these are associated with the Spil Games user ID. This user ID is automatically created by the Spil Games SDK the first time the user launches the game. Typically, they contain information related to a user’s progress. For example, preference settings, achieved levels and checkpoints, unlocked features or characters, and story progression. These game states cannot be shared with external users.
  • Public: if you plan on saving these, you are required to provide a custom user ID and provider (such as Facebook or Twitter). Typically, they contain information such as achievements, leaderboards, highest scores, and things that should be highlighted. These game states can be shared with external users.

Implementing Game States

The latest versions of the states are retrieved automatically by the Spil Games SDK at the start of the game. If a state cannot be retrieved (for example, due to a failed network connection), then the state stored locally on the user’s device is used. If this is not available, then it is treated as a new game. In addition, if a user logs on to a game using Facebook, you can request the public states of their friends by supplying their user IDs and providers.

To operate game state support, use the following code:

To listen to the available callbacks, use the following methods:

Note: There is a 2mb limit for the gamestate, sending bigger gamestates will be ignored by the backend.