preLoadGame:completion:
Pre-load Game (by Game ID)
This method performs time-consuming operations such as environment initialization, resource decompression, and runtime loading in advance before formally starting the game. Unlike preDownload, preLoad focuses on memory preparation and runtime environment readiness, aiming to achieve an instant-open experience when the user taps "Start Game".
Method Declaration
objectivec
/**
Pre-load game with game ID to prepare the runtime environment.
@param gameID The unique identifier of the game.
@param completion Called when the pre-load operation finishes.
@return An instance of id<SUDOPGameTask> to track the pre-load task.
*/
+ (id<SUDOPGameTask>)preLoadGame:(NSString *)gameID
completion:(nullable SUDOPGameOperationCompletion)completion;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| gameID | NSString * | Yes | The unique identifier of the game. |
| completion | SUDOPGameOperationCompletion | No | Callback invoked after the asynchronous pre-load finishes. On success, gameHandleProvider provides the initially generated handle information. |
Return Value
Returns an object conforming to the id<SUDOPGameTask> protocol. Developers can cancel the pre-load or observe the task status through this object.
Runtime Behavior
- Resource Confirmation: The SDK checks whether the game's local resources exist. If resources are missing, it may internally attempt to automatically trigger a download or return an error.
- Environment Initialization: The low-level script engine, graphics context, and base configuration files required to start the game are loaded into memory.
- Intermediate Result: After this interface succeeds, the game is not yet rendered to the screen, but is in a "hot-start" ready state.
Example Code
objc
[SUDOP preLoadGame:@"game_789" completion:nil];Notes
- Memory Overhead: Since
preLoadkeeps part of the game resources resident in memory, avoid pre-loading multiple different games at the same time to prevent memory overflow. - Repeated Loading: If the game is already in the pre-loaded state, calling again usually triggers the success callback immediately.
- Association with Start: The
gameHandleobtained after a successful pre-load is usually a preliminary handle; it is recommended to keep this handle consistent during the formal start.
