* @zh 创建Core实例 * @en Create Core instance * * @zh 如果实例已存在,则返回现有实例。 * @en If instance already exists, returns the existing instance. * * @param config - @zh Core配置,也可以直接传入boolean表示debug模式(向后兼容) @en Core config, can also pass boolean for debug mode (backward compatible)
(config: ICoreConfig | boolean = true)
| 295 | * ``` |
| 296 | */ |
| 297 | public static create(config: ICoreConfig | boolean = true): Core { |
| 298 | if (this._instance == null) { |
| 299 | // 向后兼容:如果传入boolean,转换为配置对象 |
| 300 | const coreConfig: ICoreConfig = typeof config === 'boolean' |
| 301 | ? { debug: config } |
| 302 | : config; |
| 303 | this._instance = new Core(coreConfig); |
| 304 | } else { |
| 305 | this._logger.warn('Core实例已创建,返回现有实例'); |
| 306 | } |
| 307 | return this._instance; |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * @zh 设置当前场景 |