Skip to content

preStartGameWithSignature:completion: ​

Pre-start Game (by Game Signature) ​

This method sits between "pre-load (preLoad)" and "formal start (startGame)". It not only completes the preparation of the runtime environment, but also triggers the initial execution of the game script (such as loading first-frame resources, establishing a server connection, etc.), while the game view (View) remains hidden or static at this point. Through this interface, an "instant pop-up" experience of the game screen can be achieved.


Method Declaration ​

objectivec
/**
 Pre-start game with a game signature. 
 This moves the game state closer to active running without displaying the UI.
 @param gameSignature The signature used to authorize the game operation.
 @param completion Called when the pre-start operation finishes.
 @return An instance of id<SUDOPGameTask> to track the pre-start task.
 */
+ (nullable id<SUDOPGameTask>)preStartGameWithSignature:(NSString *)gameSignature
                                             completion:(nullable SUDOPGameOperationCompletionBlock)completion;

Parameters ​

ParameterTypeRequiredDescription
gameSignatureNSString *YesThe game's authorization signature string.
completionSUDOPGameOperationCompletionBlockNoCallback invoked after the asynchronous pre-start finishes. Success indicates the game has run to a ready state in the background.

Return Value ​

Returns an object conforming to id<SUDOPGameTask>. It may return nil if the task cannot be created.


Runtime Behavior ​

  1. Pipeline Execution: If preLoad has not been called before, this method automatically includes all the logic of preDownload and preLoad.
  2. Script Execution: Unlike preLoad, which only loads the environment, preStart starts the game logic and triggers the game framework's onLoad or similar lifecycle hooks.
  3. Silent Running: The game completes first-frame rendering preparation in memory, but does not submit the rendered content to the screen, nor occupy audio output (depending on internal configuration), until the formal startGame is called.

Example Code ​

objc
// Suitable to call when the user enters the game lobby and is highly likely to tap "Start"
[SUDOP preStartGameWithSignature:signature completion:nil];

Notes ​

  • Performance Overhead: preStart incurs CPU consumption (because the script is already running). If the user ultimately does not start the game, be sure to clean up promptly to avoid unnecessary energy consumption.
  • Timing Suggestion: Typically called when the user taps "Enter Room" or "Get Ready".
  • State Continuity: After calling this interface, calling the startGame series of interfaces will directly reuse this pre-started state, achieving "instant open".