Skip to content

setGameStartOptions ​

Set the Game Startup Options ​

setGameStartOptions is the most core configuration interface in SUDRTGameHandle. It allows developers to define the game's runtime behavior, rendering performance, network timeouts, and debug switches via a Bundle before formally creating the game environment (calling create()).


Method Declaration ​

java
/**
 * Sets the parameter information required when starting the game.
 * * @param id      Required. The unique identifier (Game ID) of the mini-game to start.
 * @param options Optional. A Bundle object containing various configuration Keys.
 * @return boolean whether the setting succeeded.
 */
boolean setGameStartOptions(@NonNull String id, final Bundle options);

Common Configuration Items (Bundle Key) ​

These constants are defined in the SUDRTGameHandle interface and are categorized by function as follows:

1. Basic Information ​

Constant KeyTypeDescription
KEY_GAME_USER_IDStringThe unique ID of the currently logged-in user, used for in-game data isolation.
KEY_GAME_START_OPTIONS_GAME_VERSIONStringSpecifies the version of the game package to start.

2. Rendering and View ​

Constant KeyTypeDescription
KEY_GAME_VIEW_TYPEintView type. 1 for SurfaceView (default), 2 for TextureView.
KEY_GAME_START_OPTIONS_PIXEL_RATIOfloatThe ratio of logical pixels to physical pixels (DPR).
KEY_GAME_START_OPTIONS_RENDER_THREAD_MODEintRender thread mode. It is recommended to use RENDER_THREAD_MODE_AUTO.

3. Debug Options ​

Constant KeyTypeDescription
KEY_GAME_DEBUG_OPTION_ENABLE_FPSbooleanWhether to display the frame rate (FPS) monitoring panel on the screen.
KEY_GAME_DEBUG_OPTION_ENABLE_V_CONSOLEbooleanWhether to enable vConsole (the JS log debugging panel).
KEY_GAME_DEBUG_OPTION_ENABLE_DEBUGGERbooleanWhether to enable the remote debugging port.

4. Network Timeout Settings (Network) ​

  • KEY_GAME_START_OPTIONS_NETWORK_TIMEOUT_DOWNLOAD: Download timeout (ms).
  • KEY_GAME_START_OPTIONS_NETWORK_TIMEOUT_XML_HTTP_REQUEST: AJAX request timeout (ms).
  • KEY_GAME_START_OPTIONS_NETWORK_TIMEOUT_WEB_SOCKET: WebSocket connection timeout (ms).

Runtime Behavior ​

  1. Calling timing: Must be executed before calling create(). If called while the game is running, the parameters usually do not take effect immediately unless the instance is restarted.
  2. Default values: If options is passed as null or a certain Key is not set, the SDK uses the built-in default configuration (for example, multi-threaded rendering is enabled by default).
  3. Persistence: The set parameters apply throughout the entire lifecycle of this SUDRTGameHandle, until the handle is destroy()ed.

Example Code ​

java
Bundle options = new Bundle();

// 1. Set the render view to TextureView (better support for animation/layering effects)
options.putInt(SUDRTGameHandle.KEY_GAME_VIEW_TYPE, SUDRTGameHandle.GAME_VIEW_TYPE_TEXTURE_VIEW);

// 2. Enable debug features to make it easier to troubleshoot JS errors during development
options.putBoolean(SUDRTGameHandle.KEY_GAME_DEBUG_OPTION_ENABLE_V_CONSOLE, true);
options.putBoolean(SUDRTGameHandle.KEY_GAME_DEBUG_OPTION_ENABLE_FPS, true);

// 3. Set the network timeout to 10 seconds
options.putInt(SUDRTGameHandle.KEY_GAME_START_OPTIONS_NETWORK_TIMEOUT_DOWNLOAD, 10000);

// 4. Apply the configuration
boolean success = gameHandle.setGameStartOptions("demo_game_001", options);

if (success) {
    // The parameters were set successfully; you can start creating the environment
    gameHandle.create();
}

Notes ​

  • View type choice: SurfaceView offers the highest performance and is suitable for heavy games; TextureView has stronger compatibility and supports opacity animations or screenshots on the View, but incurs a slight performance loss.
  • Render thread mode: Unless you have special needs (such as requiring extremely tight synchronization with the native UI thread), keep the default RENDER_THREAD_MODE_AUTO.
  • Permissions and storage: If KEY_GAME_START_OPTIONS_LIMIT_USER_STORAGE is set, when the game storage exceeds this value, write operations at the JS layer will report an error.