SceneManager()
SceneManager - 场景管理器
管理场景切换的静态类。
负责游戏中不同场景的切换、更新、渲染,以及错误处理和系统初始化。
The static class that manages scene transitions.
Responsible for switching, updating, rendering different scenes in the game,
as well as error handling and system initialization.
Kind: global function
- SceneManager()
- .run(sceneClass)
- .initialize()
- .initGraphics()
- .preferableRendererType() ⇒
string
- .shouldUseCanvasRenderer() ⇒
boolean
- .checkWebGL()
- .checkFileAccess()
- .initAudio()
- .initInput()
- .initNwjs()
- .checkPluginErrors()
- .setupErrorHandlers()
- .requestUpdate()
- .update()
- .terminate()
- .onError(e)
- .onKeyDown(event)
- .catchException(e)
- .tickStart()
- .tickEnd()
- .updateInputData()
- .updateMain()
- .updateManagers()
- .changeScene()
- .updateScene()
- .renderScene()
- .onSceneCreate()
- .onSceneStart()
- .onSceneLoading()
- .isSceneChanging() ⇒
boolean
- .isCurrentSceneBusy() ⇒
boolean
- .isCurrentSceneStarted() ⇒
boolean
- .isNextScene(sceneClass) ⇒
boolean
- .isPreviousScene(sceneClass) ⇒
boolean
- .goto(sceneClass)
- .push(sceneClass)
- .pop()
- .exit()
- .clearStack()
- .stop()
- .prepareNextScene()
- .snap() ⇒
Bitmap
- .snapForBackground()
- .backgroundBitmap() ⇒
Bitmap
- .resume()
SceneManager.run(sceneClass)
运行游戏
Run the game
Kind: static method of SceneManager
Param | Type | Description |
---|---|---|
sceneClass | function | 初始场景类 / Initial scene class |
SceneManager.initialize()
初始化游戏系统
Initialize game system
Kind: static method of SceneManager
SceneManager.initGraphics()
初始化图形系统
Initialize graphics system
Kind: static method of SceneManager
SceneManager.preferableRendererType() ⇒ string
获取较好的渲染器类型
Get preferable renderer type
Kind: static method of SceneManager
Returns: string
- 渲染器类型 / Renderer type
SceneManager.shouldUseCanvasRenderer() ⇒ boolean
是否应该使用 Canvas 渲染
Whether should use Canvas renderer
Kind: static method of SceneManager
Returns: boolean
- 是否使用 Canvas / Whether use Canvas
SceneManager.checkWebGL()
检测是否支持 WebGL
Check WebGL support
Kind: static method of SceneManager
SceneManager.checkFileAccess()
检测是否拥有文件访问权限
Check file access permission
Kind: static method of SceneManager
SceneManager.initAudio()
初始化音频系统
Initialize audio system
Kind: static method of SceneManager
SceneManager.initInput()
初始化输入系统
Initialize input system
Kind: static method of SceneManager
SceneManager.initNwjs()
初始化 NW.js 环境
Initialize NW.js environment
Kind: static method of SceneManager
SceneManager.checkPluginErrors()
检测插件错误
Check plugin errors
Kind: static method of SceneManager
SceneManager.setupErrorHandlers()
设置错误处理者
Setup error handlers
Kind: static method of SceneManager
SceneManager.requestUpdate()
请求更新
Request update
Kind: static method of SceneManager
SceneManager.update()
更新游戏
Update game
Kind: static method of SceneManager
SceneManager.terminate()
终止游戏
Terminate game
Kind: static method of SceneManager
SceneManager.onError(e)
错误事件处理
Error event handler
Kind: static method of SceneManager
Param | Type | Description |
---|---|---|
e | Event | 错误事件 / Error event |
SceneManager.onKeyDown(event)
按键按下事件处理
F5 刷新游戏,F8 显示开发者工具(调试模式下有效)
Key down event handler
F5 refreshes the game, F8 shows developer tools (valid in debug mode)
Kind: static method of SceneManager
Param | Type | Description |
---|---|---|
event | Event | 键盘事件 / Keyboard event |
SceneManager.catchException(e)
捕捉异常
终止游戏,并在游戏界面里显示出错误日志。
Catch exception
Terminate the game and display error log in the game interface.
Kind: static method of SceneManager
Param | Type | Description |
---|---|---|
e | Error | 异常对象 / Exception object |
SceneManager.tickStart()
tick 开始
tick 为系统的相对时间单位,每执行一次 update 即为一次 tick。
Tick start
Tick is the relative time unit of the system. Each update execution is one tick.
Kind: static method of SceneManager
SceneManager.tickEnd()
tick 结束
Tick end
Kind: static method of SceneManager
SceneManager.updateInputData()
更新输入数据
Update input data
Kind: static method of SceneManager
SceneManager.updateMain()
更新主函数
Update main function
Kind: static method of SceneManager
SceneManager.updateManagers()
更新管理器
Update managers
Kind: static method of SceneManager
SceneManager.changeScene()
切换场景
Change scene
Kind: static method of SceneManager
SceneManager.updateScene()
更新场景
Update scene
Kind: static method of SceneManager
SceneManager.renderScene()
渲染场景
Render scene
Kind: static method of SceneManager
SceneManager.onSceneCreate()
当场景创建
On scene create
Kind: static method of SceneManager
SceneManager.onSceneStart()
当场景开始
On scene start
Kind: static method of SceneManager
SceneManager.onSceneLoading()
当场景加载中
On scene loading
Kind: static method of SceneManager
SceneManager.isSceneChanging() ⇒ boolean
是否场景切换中
Check if scene is changing
Kind: static method of SceneManager
Returns: boolean
- 是否切换中 / Whether changing
SceneManager.isCurrentSceneBusy() ⇒ boolean
当前场景是否繁忙
Check if current scene is busy
Kind: static method of SceneManager
Returns: boolean
- 是否繁忙 / Whether busy
SceneManager.isCurrentSceneStarted() ⇒ boolean
当前场景是否开始
Check if current scene is started
Kind: static method of SceneManager
Returns: boolean
- 是否开始 / Whether started
SceneManager.isNextScene(sceneClass) ⇒ boolean
是否下一个场景
Check if next scene
Kind: static method of SceneManager
Returns: boolean
- 是否下一个场景 / Whether next scene
Param | Type | Description |
---|---|---|
sceneClass | function | 场景类 / Scene class |
SceneManager.isPreviousScene(sceneClass) ⇒ boolean
是否上一个场景
Check if previous scene
Kind: static method of SceneManager
Returns: boolean
- 是否上一个场景 / Whether previous scene
Param | Type | Description |
---|---|---|
sceneClass | function | 场景类 / Scene class |
SceneManager.goto(sceneClass)
跳转到场景
Go to scene
Kind: static method of SceneManager
Param | Type | Description |
---|---|---|
sceneClass | function | 场景类 / Scene class |
SceneManager.push(sceneClass)
往栈末尾添加元素
Push scene to stack
Kind: static method of SceneManager
Param | Type | Description |
---|---|---|
sceneClass | function | 场景类 / Scene class |
SceneManager.pop()
取出栈末尾的元素
Pop scene from stack
Kind: static method of SceneManager
SceneManager.exit()
退出游戏
Exit game
Kind: static method of SceneManager
SceneManager.clearStack()
清空栈
Clear stack
Kind: static method of SceneManager
SceneManager.stop()
停止游戏
Stop game
Kind: static method of SceneManager
SceneManager.prepareNextScene()
准备下一个场景
Prepare next scene
Kind: static method of SceneManager
SceneManager.snap() ⇒ Bitmap
快照
将场景绘制成位图。
Snapshot
Draw the scene as a bitmap.
Kind: static method of SceneManager
Returns: Bitmap
- 快照位图 / Snapshot bitmap
SceneManager.snapForBackground()
快照作为背景
在切换场景的时候将当前场景绘制成图片作为背景。
Snapshot for background
Draw the current scene as an image for background when switching scenes.
Kind: static method of SceneManager
SceneManager.backgroundBitmap() ⇒ Bitmap
获取背景位图
Get background bitmap
Kind: static method of SceneManager
Returns: Bitmap
- 背景位图 / Background bitmap
SceneManager.resume()
继续游戏
Resume game
Kind: static method of SceneManager