diff --git a/codes/games/client/Edit/Settings.ini b/codes/games/client/Edit/Settings.ini index bc93c87..17b5a26 100644 --- a/codes/games/client/Edit/Settings.ini +++ b/codes/games/client/Edit/Settings.ini @@ -123,16 +123,16 @@ DocumentTypeKeyWordsFile1= DocumentTypeFunctionRegExp1= [MRUFiles] -MRUItem1=G:\Works\YouleGames\codes\games\client\Projects\Project1\js\gamemain.js -MRUItem2=G:\Works\YouleGames\codes\games\client\Projects\Spine\js\gamemain.js -MRUItem3=G:\Works\YouleGames\codes\games\client\Projects\Spine\index.html -MRUItem4=G:\Works\YouleGames\games\games\Projects\clinet\gamehall\js\gamemain.js -MRUItem5=G:\Works\YouleGames\games\games\Projects\clinet\zpy\js\gamemain.js -MRUItem6=G:\Works\YouleGames\games\games\Projects\Project1\js\gamemain.js -MRUItem7=G:\Works\YouleGames\games\games\Projects\clinet\sangelaok\js\gamemain.js -MRUItem8=G:\Works\YouleGames\games\games\Projects\clinet\niuniu\js\gamemain.js -MRUItem9=G:\Works\YouleGames\games\games\Projects\clinet\guanpai-jx\js\gamemain.js -MRUItem10=G:\Works\YouleGames\games\games\Projects\clinet\doudizhu\js\gamemain.js +MRUItem1=G:\Works\YouleGames\codes\games\client\Projects\Spine\js\gamemain.js +MRUItem2=G:\Works\YouleGames\codes\games\client\Projects\Project2\js\gamemain.js +MRUItem3=G:\Works\YouleGames\codes\games\client\Projects\Project1\js\gamemain.js +MRUItem4=G:\Works\YouleGames\codes\games\client\Projects\Spine\index.html +MRUItem5=G:\Works\YouleGames\games\games\Projects\clinet\gamehall\js\gamemain.js +MRUItem6=G:\Works\YouleGames\games\games\Projects\clinet\zpy\js\gamemain.js +MRUItem7=G:\Works\YouleGames\games\games\Projects\Project1\js\gamemain.js +MRUItem8=G:\Works\YouleGames\games\games\Projects\clinet\sangelaok\js\gamemain.js +MRUItem9=G:\Works\YouleGames\games\games\Projects\clinet\niuniu\js\gamemain.js +MRUItem10=G:\Works\YouleGames\games\games\Projects\clinet\guanpai-jx\js\gamemain.js [MRUFindText] MRUItem1=ÅäÖà diff --git a/codes/games/client/Projects/Spine/docs/SpineåŠ¨ç”»é›†æˆæ‰‹å†Œ.md b/codes/games/client/Projects/Spine/docs/SpineåŠ¨ç”»é›†æˆæ‰‹å†Œ.md index e7398eb..23c6f2a 100644 --- a/codes/games/client/Projects/Spine/docs/SpineåŠ¨ç”»é›†æˆæ‰‹å†Œ.md +++ b/codes/games/client/Projects/Spine/docs/SpineåŠ¨ç”»é›†æˆæ‰‹å†Œ.md @@ -375,9 +375,43 @@ gameabc_face.spineMgr.playQueue("hero", ["intro", "idle"], false); --- -### 4.14 remove(id) +### 4.14 stop(id) -**é”€æ¯æŒ‡å®š Spine 实例,释放内存。** +**åœæ­¢æŒ‡å®š Spine 实例的动画并éšè—。** 实例ä¿ç•™åœ¨å†…存中,å¯é𿗶釿–°æ’­æ”¾ã€‚ +与 `setVisible(false)` ä¸åŒï¼Œ`stop` 会彻底清空动画轨é“ã€é‡ç½®éª¨éª¼å§¿æ€ï¼Œå¹¶æ¸…除待执行命令队列。 + +```javascript +// åœæ­¢å•个 Spine 动画(ä¿ç•™å®žä¾‹ï¼Œå¯é‡æ’­ï¼‰ +gameabc_face.spineMgr.stop("hero"); + +// 之åŽå¯ä»¥é‡æ–°æ’­æ”¾ +gameabc_face.spineMgr.playOnce("hero", "attack"); +``` + +| 行为 | 说明 | +|------|------| +| éšè— | `visible = false` | +| æ¸…ç©ºåŠ¨ç”»è½¨é“ | `state.clearTracks()` | +| é‡ç½®éª¨éª¼å§¿æ€ | `skeleton.setToSetupPose()` | +| 清除待执行命令 | 删除 `_pendingCmds[id]` | +| 清除自动éšè—标记 | `_hideOnComplete = false` | + +--- + +### 4.15 stopAll() + +**åœæ­¢æ‰€æœ‰ Spine 实例的动画并éšè—。** 所有实例ä¿ç•™åœ¨å†…存中,å¯é𿗶釿–°æ’­æ”¾ã€‚ + +```javascript +// åœæ­¢å…¨éƒ¨ Spine åŠ¨ç”»ï¼ˆå¦‚ï¼šåˆ‡æ¢æ¸¸æˆåœºæ™¯æ—¶ï¼‰ +gameabc_face.spineMgr.stopAll(); +``` + +--- + +### 4.16 remove(id) + +**å½»åº•é”€æ¯æŒ‡å®š Spine 实例,释放内存。** 销æ¯åŽæ— æ³•釿–°æ’­æ”¾ï¼Œéœ€è¦é‡æ–° `load` 或自动加载。 ```javascript gameabc_face.spineMgr.remove("hero"); @@ -385,15 +419,17 @@ gameabc_face.spineMgr.remove("hero"); --- -### 4.15 removeAll() +### 4.17 removeAll() -**é”€æ¯æ‰€æœ‰ Spine 实例。** +**å½»åº•é”€æ¯æ‰€æœ‰ Spine 实例,释放内存。** ```javascript gameabc_face.spineMgr.removeAll(); ``` -### 4.16 spine_onComplete(spineId, animName, trackIndex) *(事件回调)* +--- + +### 4.18 spine_onComplete(spineId, animName, trackIndex) *(事件回调)* **动画完æˆå›žè°ƒã€‚æ¯æ¬¡åŠ¨ç”»æ’­æ”¾ä¸€è½®ç»“æŸæ—¶è§¦å‘。** 在 `js/Spine_Event.js` 中定义。 @@ -418,7 +454,7 @@ gameabc_face.spine_onComplete = function(spineId, animName, trackIndex) { --- -### 4.17 spine_onEvent(spineId, eventName, intValue, floatValue, stringValue) *(事件回调)* +### 4.19 spine_onEvent(spineId, eventName, intValue, floatValue, stringValue) *(事件回调)* **自定义事件回调。当动画播放到 Spine 编辑器中定义的 Event 关键帧时触å‘。** 在 `js/Spine_Event.js` 中定义。 @@ -449,7 +485,7 @@ gameabc_face.spine_onEvent = function(spineId, eventName, intValue, floatValue, ## 5. 事件系统(详细说明) Spine 动画在è¿è¡Œæ—¶ä¼šè§¦å‘两类事件,回调定义在 `js/Spine_Event.js` 中。 -API ç­¾åè§ [4.16](#416-spine_oncompletespineid-animname-trackindex--事件回调) å’Œ [4.17](#417-spine_oneventspineid-eventname-intvalue-floatvalue-stringvalue--事件回调)。 +API ç­¾åè§ [4.18](#418-spine_oncompletespineid-animname-trackindex--事件回调) å’Œ [4.19](#419-spine_oneventspineid-eventname-intvalue-floatvalue-stringvalue--事件回调)。 ### 5.1 动画完æˆäº‹ä»¶ spine_onComplete @@ -674,6 +710,7 @@ gameabc_face.gamemydraw = function(gameid, spid, times, timelong) { - Canvas 2D 渲染性能有é™ï¼Œå»ºè®®åŒå± Spine 实例ä¸è¶…过 **5-8 个** - ä¸å¯è§çš„实例调用 `setVisible(id, false)`,跳过渲染和更新 +- åœºæ™¯åˆ‡æ¢æ—¶è°ƒç”¨ `stopAll()` 一键关闭所有 Spine 动画 - ä¸å†éœ€è¦çš„实例调用 `remove(id)` 释放内存 ### 8.3 å‡å°‘éª¨éª¼å¤æ‚度 diff --git a/codes/games/client/Projects/Spine/js/SpineMgr.js b/codes/games/client/Projects/Spine/js/SpineMgr.js index db3fd98..9a989b0 100644 --- a/codes/games/client/Projects/Spine/js/SpineMgr.js +++ b/codes/games/client/Projects/Spine/js/SpineMgr.js @@ -355,12 +355,35 @@ var SpineMgr = { } }, + stop: function(id) { + var e = this._entries[id]; + if (!e) return; + e.visible = false; + e._hideOnComplete = false; + e._hideAfterCompletes = 0; + delete this._pendingCmds[id]; + if (e.state) { + e.state.clearTracks(); + } + if (e.skeleton) { + e.skeleton.setToSetupPose(); + } + }, + + stopAll: function() { + for (var id in this._entries) { + this.stop(id); + } + }, + remove: function(id) { delete this._entries[id]; + delete this._pendingCmds[id]; }, removeAll: function() { this._entries = {}; + this._pendingCmds = {}; } };