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 Key | Type | Description |
|---|---|---|
| KEY_GAME_USER_ID | String | The unique ID of the currently logged-in user, used for in-game data isolation. |
| KEY_GAME_START_OPTIONS_GAME_VERSION | String | Specifies the version of the game package to start. |
2. Rendering and View
| Constant Key | Type | Description |
|---|---|---|
| KEY_GAME_VIEW_TYPE | int | View type. 1 for SurfaceView (default), 2 for TextureView. |
| KEY_GAME_START_OPTIONS_PIXEL_RATIO | float | The ratio of logical pixels to physical pixels (DPR). |
| KEY_GAME_START_OPTIONS_RENDER_THREAD_MODE | int | Render thread mode. It is recommended to use RENDER_THREAD_MODE_AUTO. |
3. Debug Options
| Constant Key | Type | Description |
|---|---|---|
| KEY_GAME_DEBUG_OPTION_ENABLE_FPS | boolean | Whether to display the frame rate (FPS) monitoring panel on the screen. |
| KEY_GAME_DEBUG_OPTION_ENABLE_V_CONSOLE | boolean | Whether to enable vConsole (the JS log debugging panel). |
| KEY_GAME_DEBUG_OPTION_ENABLE_DEBUGGER | boolean | Whether 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
- 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. - Default values: If
optionsis passed asnullor a certain Key is not set, the SDK uses the built-in default configuration (for example, multi-threaded rendering is enabled by default). - Persistence: The set parameters apply throughout the entire lifecycle of this
SUDRTGameHandle, until the handle isdestroy()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:
SurfaceViewoffers the highest performance and is suitable for heavy games;TextureViewhas 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_STORAGEis set, when the game storage exceeds this value, write operations at the JS layer will report an error.
