diff --git a/assets/prefabs/PageLevel.ts b/assets/prefabs/PageLevel.ts index 3d1d0cb..7aebbf0 100644 --- a/assets/prefabs/PageLevel.ts +++ b/assets/prefabs/PageLevel.ts @@ -217,6 +217,9 @@ export class PageLevel extends BaseView { /** 本次通关弹窗使用的已通关数量 */ private _passModalCompletedLevelCount: number | null = null; + /** 本次通关弹窗动画起点(通关前)的已通关数量;为 null 表示不播动画 */ + private _passModalPreviousCompletedLevelCount: number | null = null; + /** 错误弹窗实例 */ private _wrongModalNode: Node | null = null; @@ -1570,8 +1573,11 @@ export class PageLevel extends BaseView { private reportLevelCompleted(levelId: string, timeSpent: number): void { if (!this._isShareMode) { // 乐观更新通关计数(用于称号展示) + const previousCount = AuthManager.instance.completedLevelCount; AuthManager.instance.addCompletedLevelCount(); this._passModalCompletedLevelCount = AuthManager.instance.completedLevelCount; + // 本次预期为首次通关,起点 = 通关前计数;如果回调回退,则清掉避免误播动画 + this._passModalPreviousCompletedLevelCount = previousCount; void StaminaManager.instance.completeLevel(levelId, timeSpent).then((result) => { if (result) { @@ -1582,6 +1588,7 @@ export class PageLevel extends BaseView { // 非首次通关,回退乐观更新 AuthManager.instance.addCompletedLevelCount(-1); this._passModalCompletedLevelCount = AuthManager.instance.completedLevelCount; + this._passModalPreviousCompletedLevelCount = null; } console.log(`[PageLevel] 通关上报成功,首次通关: ${result.firstClear}, 有下一关: ${!!result.nextLevel}`); } @@ -1590,6 +1597,7 @@ export class PageLevel extends BaseView { } this._passModalCompletedLevelCount = null; + this._passModalPreviousCompletedLevelCount = null; // fire-and-forget: errors are logged inside reportLevelProgress void ShareManager.instance.reportLevelProgress(levelId, true, timeSpent); } @@ -1631,9 +1639,17 @@ export class PageLevel extends BaseView { // 获取 PassModal 组件并设置回调 const passModal = modalNode.getComponent(PassModal); if (passModal) { + const completedCount = this._getPassModalCompletedLevelCount(); + const titleInfo = AchievementTitleManager.getTitleInfo(completedCount); + const previousCompletedCount = this._passModalPreviousCompletedLevelCount; + const previousTitleInfo = (previousCompletedCount !== null && previousCompletedCount !== completedCount) + ? AchievementTitleManager.getTitleInfo(previousCompletedCount) + : undefined; + passModal.setParams({ levelIndex: this.getDisplayLevelNumber(), - titleInfo: AchievementTitleManager.getTitleInfo(this._getPassModalCompletedLevelCount()) + titleInfo, + previousTitleInfo }); passModal.setCallbacks({ onNextLevel: () => { @@ -1645,6 +1661,8 @@ export class PageLevel extends BaseView { console.log('[PageLevel] 分享完成'); } }); + // 动画消费完一次后清除起点,避免弹窗多次打开时复用 + this._passModalPreviousCompletedLevelCount = null; // 手动调用 onViewLoad 和 onViewShow passModal.onViewLoad(); passModal.onViewShow(); diff --git a/assets/prefabs/PageWriteLevels.prefab b/assets/prefabs/PageWriteLevels.prefab index 5349b23..b78842b 100644 --- a/assets/prefabs/PageWriteLevels.prefab +++ b/assets/prefabs/PageWriteLevels.prefab @@ -25,47 +25,50 @@ "__id__": 10 }, { - "__id__": 20 + "__id__": 26 }, { - "__id__": 30 + "__id__": 34 }, { - "__id__": 46 + "__id__": 42 }, { - "__id__": 52 + "__id__": 58 }, { - "__id__": 72 + "__id__": 64 }, { - "__id__": 92 + "__id__": 84 }, { - "__id__": 98 + "__id__": 104 }, { - "__id__": 124 + "__id__": 110 }, { - "__id__": 144 + "__id__": 136 + }, + { + "__id__": 156 } ], "_active": true, "_components": [ { - "__id__": 176 + "__id__": 188 }, { - "__id__": 178 + "__id__": 190 }, { - "__id__": 180 + "__id__": 192 } ], "_prefab": { - "__id__": 182 + "__id__": 194 }, "_lpos": { "__type__": "cc.Vec3", @@ -255,35 +258,39 @@ }, { "__type__": "cc.Node", - "_name": "IconBack", + "_name": "BtnBack", "_objFlags": 0, "__editorExtras__": {}, "_parent": { "__id__": 1 }, - "_children": [], + "_children": [ + { + "__id__": 11 + } + ], "_active": true, "_components": [ - { - "__id__": 11 - }, - { - "__id__": 13 - }, - { - "__id__": 15 - }, { "__id__": 17 + }, + { + "__id__": 19 + }, + { + "__id__": 21 + }, + { + "__id__": 23 } ], "_prefab": { - "__id__": 19 + "__id__": 25 }, "_lpos": { "__type__": "cc.Vec3", - "x": -433.514, - "y": 968.049, + "x": -401.653, + "y": 882.059, "z": 0 }, "_lrot": { @@ -295,8 +302,58 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 1, - "y": 1, + "x": 0.7, + "y": 0.7, + "z": 1 + }, + "_mobility": 0, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "flatIconBack", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 10 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 12 + }, + { + "__id__": 14 + } + ], + "_prefab": { + "__id__": 16 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 6.61, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 0.25, + "y": 0.25, "z": 1 }, "_mobility": 0, @@ -309,6 +366,92 @@ }, "_id": "" }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 11 + }, + "_enabled": true, + "__prefab": { + "__id__": 13 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 472, + "height": 399 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "935mu62slKAq8PLzpeNUaQ" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 11 + }, + "_enabled": true, + "__prefab": { + "__id__": 15 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_spriteFrame": { + "__uuid__": "568a4811-9616-47c0-a961-bb2ad2854cdb@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_type": 0, + "_fillType": 0, + "_sizeMode": 1, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_useGrayscale": false, + "_atlas": null, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "afNZSDzjZLDrwd1naLyDeJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "2bwKQ6KEpLQrV8Ey6QQ4uv", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, { "__type__": "cc.UITransform", "_name": "", @@ -319,12 +462,12 @@ }, "_enabled": true, "__prefab": { - "__id__": 12 + "__id__": 18 }, "_contentSize": { "__type__": "cc.Size", - "width": 108, - "height": 108 + "width": 200, + "height": 200 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -347,7 +490,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 14 + "__id__": 20 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -360,12 +503,12 @@ "a": 255 }, "_spriteFrame": { - "__uuid__": "9c27734d-854f-476b-961d-d1b92c75f8c0@f9941", + "__uuid__": "ba58112d-788c-465d-a2f3-46b468026d03@f9941", "__expectedType__": "cc.SpriteFrame" }, - "_type": 0, + "_type": 1, "_fillType": 0, - "_sizeMode": 1, + "_sizeMode": 0, "_fillCenter": { "__type__": "cc.Vec2", "x": 0, @@ -392,13 +535,13 @@ }, "_enabled": true, "__prefab": { - "__id__": 16 + "__id__": 22 }, "_alignFlags": 9, "_target": null, - "_left": 52.48599999999999, + "_left": 68.34699999999998, "_right": 0, - "_top": 57.95100000000002, + "_top": 127.94100000000003, "_bottom": 0, "_horizontalCenter": 0, "_verticalCenter": 0, @@ -411,7 +554,7 @@ "_originalWidth": 0, "_originalHeight": 0, "_alignMode": 2, - "_lockFlags": 0, + "_lockFlags": 9, "_id": "" }, { @@ -428,11 +571,11 @@ }, "_enabled": true, "__prefab": { - "__id__": 18 + "__id__": 24 }, "clickEvents": [], "_interactable": true, - "_transition": 0, + "_transition": 3, "_normalColor": { "__type__": "cc.Color", "r": 255, @@ -487,6 +630,207 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": null }, + { + "__type__": "cc.Node", + "_name": "Title", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 27 + }, + { + "__id__": 29 + }, + { + "__id__": 31 + } + ], + "_prefab": { + "__id__": 33 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -47.58100000000002, + "y": 881.3830000000002, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_mobility": 0, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 26 + }, + "_enabled": true, + "__prefab": { + "__id__": 28 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 534.7578125, + "height": 108.8 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "1fD6kW3DZN76IftlCaTWZ6" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 26 + }, + "_enabled": true, + "__prefab": { + "__id__": 30 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 198, + "b": 78, + "a": 255 + }, + "_string": "从已闯关题目中选出6道", + "_horizontalAlign": 1, + "_verticalAlign": 1, + "_actualFontSize": 50, + "_fontSize": 50, + "_fontFamily": "Arial", + "_lineHeight": 80, + "_overflow": 0, + "_enableWrapText": true, + "_font": { + "__uuid__": "fb4acba6-6bc7-4eb3-be34-8f2ac9823a80", + "__expectedType__": "cc.TTFFont" + }, + "_isSystemFontUsed": false, + "_spacingX": 0, + "_isItalic": false, + "_isBold": true, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_enableOutline": true, + "_outlineColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_outlineWidth": 4, + "_enableShadow": false, + "_shadowColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_shadowOffset": { + "__type__": "cc.Vec2", + "x": 2, + "y": 2 + }, + "_shadowBlur": 2, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "5eYbpedb1NmJ7vHUGZB5/m" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 26 + }, + "_enabled": true, + "__prefab": { + "__id__": 32 + }, + "_alignFlags": 9, + "_target": null, + "_left": 225.04009374999998, + "_right": 0, + "_top": 144.21699999999993, + "_bottom": 0, + "_horizontalCenter": 0, + "_verticalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_alignMode": 2, + "_lockFlags": 0, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "f9vG+G6E5Nu57B7T4ZtCLJ" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "12CJpBYllPtJT1ErTJCgwy", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, { "__type__": "cc.Node", "_name": "DataButton", @@ -499,25 +843,22 @@ "_active": true, "_components": [ { - "__id__": 21 + "__id__": 35 }, { - "__id__": 23 + "__id__": 37 }, { - "__id__": 25 - }, - { - "__id__": 27 + "__id__": 39 } ], "_prefab": { - "__id__": 29 + "__id__": 41 }, "_lpos": { "__type__": "cc.Vec3", "x": 300.236, - "y": 963.872, + "y": -240.01199999999986, "z": 0 }, "_lrot": { @@ -549,11 +890,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 20 + "__id__": 34 }, "_enabled": true, "__prefab": { - "__id__": 22 + "__id__": 36 }, "_contentSize": { "__type__": "cc.Size", @@ -577,11 +918,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 20 + "__id__": 34 }, "_enabled": true, "__prefab": { - "__id__": 24 + "__id__": 38 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -622,11 +963,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 20 + "__id__": 34 }, "_enabled": true, "__prefab": { - "__id__": 26 + "__id__": 40 }, "clickEvents": [], "_interactable": true, @@ -666,7 +1007,7 @@ "_duration": 0.1, "_zoomScale": 1.2, "_target": { - "__id__": 20 + "__id__": 34 }, "_id": "" }, @@ -674,42 +1015,6 @@ "__type__": "cc.CompPrefabInfo", "fileId": "f0jo8QdtFP66vZo36FK2UA" }, - { - "__type__": "cc.Widget", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 20 - }, - "_enabled": true, - "__prefab": { - "__id__": 28 - }, - "_alignFlags": 33, - "_target": null, - "_left": 0, - "_right": 86.964, - "_top": 63.728000000000065, - "_bottom": 0, - "_horizontalCenter": 0, - "_verticalCenter": 0, - "_isAbsLeft": true, - "_isAbsRight": true, - "_isAbsTop": true, - "_isAbsBottom": true, - "_isAbsHorizontalCenter": true, - "_isAbsVerticalCenter": true, - "_originalWidth": 0, - "_originalHeight": 0, - "_alignMode": 2, - "_lockFlags": 0, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "26BrkBdxpES7VckaVkd75V" - }, { "__type__": "cc.PrefabInfo", "root": { @@ -733,20 +1038,20 @@ }, "_children": [ { - "__id__": 31 + "__id__": 43 }, { - "__id__": 37 + "__id__": 49 } ], "_active": true, "_components": [ { - "__id__": 43 + "__id__": 55 } ], "_prefab": { - "__id__": 45 + "__id__": 57 }, "_lpos": { "__type__": "cc.Vec3", @@ -783,20 +1088,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 30 + "__id__": 42 }, "_children": [], "_active": true, "_components": [ { - "__id__": 32 + "__id__": 44 }, { - "__id__": 34 + "__id__": 46 } ], "_prefab": { - "__id__": 36 + "__id__": 48 }, "_lpos": { "__type__": "cc.Vec3", @@ -833,11 +1138,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 31 + "__id__": 43 }, "_enabled": true, "__prefab": { - "__id__": 33 + "__id__": 45 }, "_contentSize": { "__type__": "cc.Size", @@ -861,11 +1166,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 31 + "__id__": 43 }, "_enabled": true, "__prefab": { - "__id__": 35 + "__id__": 47 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -919,20 +1224,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 30 + "__id__": 42 }, "_children": [], "_active": true, "_components": [ { - "__id__": 38 + "__id__": 50 }, { - "__id__": 40 + "__id__": 52 } ], "_prefab": { - "__id__": 42 + "__id__": 54 }, "_lpos": { "__type__": "cc.Vec3", @@ -969,11 +1274,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 37 + "__id__": 49 }, "_enabled": true, "__prefab": { - "__id__": 39 + "__id__": 51 }, "_contentSize": { "__type__": "cc.Size", @@ -997,11 +1302,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 37 + "__id__": 49 }, "_enabled": true, "__prefab": { - "__id__": 41 + "__id__": 53 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1081,11 +1386,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 30 + "__id__": 42 }, "_enabled": true, "__prefab": { - "__id__": 44 + "__id__": 56 }, "_contentSize": { "__type__": "cc.Size", @@ -1128,14 +1433,14 @@ "_active": true, "_components": [ { - "__id__": 47 + "__id__": 59 }, { - "__id__": 49 + "__id__": 61 } ], "_prefab": { - "__id__": 51 + "__id__": 63 }, "_lpos": { "__type__": "cc.Vec3", @@ -1172,11 +1477,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 46 + "__id__": 58 }, "_enabled": true, "__prefab": { - "__id__": 48 + "__id__": 60 }, "_contentSize": { "__type__": "cc.Size", @@ -1200,11 +1505,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 46 + "__id__": 58 }, "_enabled": true, "__prefab": { - "__id__": 50 + "__id__": 62 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1262,26 +1567,26 @@ }, "_children": [ { - "__id__": 53 + "__id__": 65 }, { - "__id__": 59 + "__id__": 71 } ], "_active": true, "_components": [ { - "__id__": 65 + "__id__": 77 }, { - "__id__": 67 + "__id__": 79 }, { - "__id__": 69 + "__id__": 81 } ], "_prefab": { - "__id__": 71 + "__id__": 83 }, "_lpos": { "__type__": "cc.Vec3", @@ -1318,20 +1623,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 52 + "__id__": 64 }, "_children": [], "_active": true, "_components": [ { - "__id__": 54 + "__id__": 66 }, { - "__id__": 56 + "__id__": 68 } ], "_prefab": { - "__id__": 58 + "__id__": 70 }, "_lpos": { "__type__": "cc.Vec3", @@ -1368,11 +1673,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 53 + "__id__": 65 }, "_enabled": true, "__prefab": { - "__id__": 55 + "__id__": 67 }, "_contentSize": { "__type__": "cc.Size", @@ -1396,11 +1701,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 53 + "__id__": 65 }, "_enabled": true, "__prefab": { - "__id__": 57 + "__id__": 69 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1454,20 +1759,20 @@ "_objFlags": 512, "__editorExtras__": {}, "_parent": { - "__id__": 52 + "__id__": 64 }, "_children": [], "_active": true, "_components": [ { - "__id__": 60 + "__id__": 72 }, { - "__id__": 62 + "__id__": 74 } ], "_prefab": { - "__id__": 64 + "__id__": 76 }, "_lpos": { "__type__": "cc.Vec3", @@ -1504,11 +1809,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 59 + "__id__": 71 }, "_enabled": true, "__prefab": { - "__id__": 61 + "__id__": 73 }, "_contentSize": { "__type__": "cc.Size", @@ -1532,11 +1837,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 59 + "__id__": 71 }, "_enabled": true, "__prefab": { - "__id__": 63 + "__id__": 75 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1616,11 +1921,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 52 + "__id__": 64 }, "_enabled": true, "__prefab": { - "__id__": 66 + "__id__": 78 }, "_contentSize": { "__type__": "cc.Size", @@ -1644,11 +1949,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 52 + "__id__": 64 }, "_enabled": true, "__prefab": { - "__id__": 68 + "__id__": 80 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1689,11 +1994,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 52 + "__id__": 64 }, "_enabled": true, "__prefab": { - "__id__": 70 + "__id__": 82 }, "clickEvents": [], "_interactable": true, @@ -1733,7 +2038,7 @@ "_duration": 0.1, "_zoomScale": 1.2, "_target": { - "__id__": 52 + "__id__": 64 }, "_id": "" }, @@ -1764,26 +2069,26 @@ }, "_children": [ { - "__id__": 73 + "__id__": 85 }, { - "__id__": 79 + "__id__": 91 } ], "_active": true, "_components": [ { - "__id__": 85 + "__id__": 97 }, { - "__id__": 87 + "__id__": 99 }, { - "__id__": 89 + "__id__": 101 } ], "_prefab": { - "__id__": 91 + "__id__": 103 }, "_lpos": { "__type__": "cc.Vec3", @@ -1820,20 +2125,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 72 + "__id__": 84 }, "_children": [], "_active": true, "_components": [ { - "__id__": 74 + "__id__": 86 }, { - "__id__": 76 + "__id__": 88 } ], "_prefab": { - "__id__": 78 + "__id__": 90 }, "_lpos": { "__type__": "cc.Vec3", @@ -1870,11 +2175,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 73 + "__id__": 85 }, "_enabled": true, "__prefab": { - "__id__": 75 + "__id__": 87 }, "_contentSize": { "__type__": "cc.Size", @@ -1898,11 +2203,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 73 + "__id__": 85 }, "_enabled": true, "__prefab": { - "__id__": 77 + "__id__": 89 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1956,20 +2261,20 @@ "_objFlags": 512, "__editorExtras__": {}, "_parent": { - "__id__": 72 + "__id__": 84 }, "_children": [], "_active": true, "_components": [ { - "__id__": 80 + "__id__": 92 }, { - "__id__": 82 + "__id__": 94 } ], "_prefab": { - "__id__": 84 + "__id__": 96 }, "_lpos": { "__type__": "cc.Vec3", @@ -2006,11 +2311,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 79 + "__id__": 91 }, "_enabled": true, "__prefab": { - "__id__": 81 + "__id__": 93 }, "_contentSize": { "__type__": "cc.Size", @@ -2034,11 +2339,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 79 + "__id__": 91 }, "_enabled": true, "__prefab": { - "__id__": 83 + "__id__": 95 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2118,11 +2423,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 72 + "__id__": 84 }, "_enabled": true, "__prefab": { - "__id__": 86 + "__id__": 98 }, "_contentSize": { "__type__": "cc.Size", @@ -2146,11 +2451,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 72 + "__id__": 84 }, "_enabled": true, "__prefab": { - "__id__": 88 + "__id__": 100 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2191,11 +2496,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 72 + "__id__": 84 }, "_enabled": true, "__prefab": { - "__id__": 90 + "__id__": 102 }, "clickEvents": [], "_interactable": true, @@ -2235,7 +2540,7 @@ "_duration": 0.1, "_zoomScale": 1.2, "_target": { - "__id__": 72 + "__id__": 84 }, "_id": "" }, @@ -2268,14 +2573,14 @@ "_active": true, "_components": [ { - "__id__": 93 + "__id__": 105 }, { - "__id__": 95 + "__id__": 107 } ], "_prefab": { - "__id__": 97 + "__id__": 109 }, "_lpos": { "__type__": "cc.Vec3", @@ -2312,11 +2617,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 92 + "__id__": 104 }, "_enabled": true, "__prefab": { - "__id__": 94 + "__id__": 106 }, "_contentSize": { "__type__": "cc.Size", @@ -2340,11 +2645,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 92 + "__id__": 104 }, "_enabled": true, "__prefab": { - "__id__": 96 + "__id__": 108 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2401,30 +2706,30 @@ "__id__": 1 }, "_children": [ - { - "__id__": 99 - }, - { - "__id__": 105 - }, { "__id__": 111 + }, + { + "__id__": 117 + }, + { + "__id__": 123 } ], "_active": true, "_components": [ { - "__id__": 117 + "__id__": 129 }, { - "__id__": 119 + "__id__": 131 }, { - "__id__": 121 + "__id__": 133 } ], "_prefab": { - "__id__": 123 + "__id__": 135 }, "_lpos": { "__type__": "cc.Vec3", @@ -2461,20 +2766,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 98 + "__id__": 110 }, "_children": [], "_active": false, "_components": [ { - "__id__": 100 + "__id__": 112 }, { - "__id__": 102 + "__id__": 114 } ], "_prefab": { - "__id__": 104 + "__id__": 116 }, "_lpos": { "__type__": "cc.Vec3", @@ -2511,11 +2816,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 99 + "__id__": 111 }, "_enabled": true, "__prefab": { - "__id__": 101 + "__id__": 113 }, "_contentSize": { "__type__": "cc.Size", @@ -2539,11 +2844,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 99 + "__id__": 111 }, "_enabled": true, "__prefab": { - "__id__": 103 + "__id__": 115 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2623,20 +2928,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 98 + "__id__": 110 }, "_children": [], "_active": true, "_components": [ { - "__id__": 106 + "__id__": 118 }, { - "__id__": 108 + "__id__": 120 } ], "_prefab": { - "__id__": 110 + "__id__": 122 }, "_lpos": { "__type__": "cc.Vec3", @@ -2673,11 +2978,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 105 + "__id__": 117 }, "_enabled": true, "__prefab": { - "__id__": 107 + "__id__": 119 }, "_contentSize": { "__type__": "cc.Size", @@ -2701,11 +3006,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 105 + "__id__": 117 }, "_enabled": true, "__prefab": { - "__id__": 109 + "__id__": 121 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2785,20 +3090,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 98 + "__id__": 110 }, "_children": [], "_active": true, "_components": [ { - "__id__": 112 + "__id__": 124 }, { - "__id__": 114 + "__id__": 126 } ], "_prefab": { - "__id__": 116 + "__id__": 128 }, "_lpos": { "__type__": "cc.Vec3", @@ -2835,11 +3140,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 111 + "__id__": 123 }, "_enabled": true, "__prefab": { - "__id__": 113 + "__id__": 125 }, "_contentSize": { "__type__": "cc.Size", @@ -2863,11 +3168,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 111 + "__id__": 123 }, "_enabled": true, "__prefab": { - "__id__": 115 + "__id__": 127 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2921,11 +3226,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 98 + "__id__": 110 }, "_enabled": true, "__prefab": { - "__id__": 118 + "__id__": 130 }, "_contentSize": { "__type__": "cc.Size", @@ -2949,21 +3254,21 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 98 + "__id__": 110 }, "_enabled": true, "__prefab": { - "__id__": 120 + "__id__": 132 }, "editingDidBegan": [], "textChanged": [], "editingDidEnded": [], "editingReturn": [], "_textLabel": { - "__id__": 102 + "__id__": 114 }, "_placeholderLabel": { - "__id__": 108 + "__id__": 120 }, "_returnType": 0, "_string": "", @@ -2984,11 +3289,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 98 + "__id__": 110 }, "_enabled": true, "__prefab": { - "__id__": 122 + "__id__": 134 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -3043,23 +3348,23 @@ }, "_children": [ { - "__id__": 125 + "__id__": 137 } ], "_active": true, "_components": [ { - "__id__": 137 + "__id__": 149 }, { - "__id__": 139 + "__id__": 151 }, { - "__id__": 141 + "__id__": 153 } ], "_prefab": { - "__id__": 143 + "__id__": 155 }, "_lpos": { "__type__": "cc.Vec3", @@ -3096,27 +3401,27 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 124 + "__id__": 136 }, "_children": [ { - "__id__": 126 + "__id__": 138 } ], "_active": true, "_components": [ { - "__id__": 130 + "__id__": 142 }, { - "__id__": 132 + "__id__": 144 }, { - "__id__": 134 + "__id__": 146 } ], "_prefab": { - "__id__": 136 + "__id__": 148 }, "_lpos": { "__type__": "cc.Vec3", @@ -3153,17 +3458,17 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 125 + "__id__": 137 }, "_children": [], "_active": true, "_components": [ { - "__id__": 127 + "__id__": 139 } ], "_prefab": { - "__id__": 129 + "__id__": 141 }, "_lpos": { "__type__": "cc.Vec3", @@ -3200,11 +3505,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 126 + "__id__": 138 }, "_enabled": true, "__prefab": { - "__id__": 128 + "__id__": 140 }, "_contentSize": { "__type__": "cc.Size", @@ -3241,11 +3546,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 125 + "__id__": 137 }, "_enabled": true, "__prefab": { - "__id__": 131 + "__id__": 143 }, "_contentSize": { "__type__": "cc.Size", @@ -3269,11 +3574,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 125 + "__id__": 137 }, "_enabled": true, "__prefab": { - "__id__": 133 + "__id__": 145 }, "_type": 0, "_inverted": false, @@ -3291,11 +3596,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 125 + "__id__": 137 }, "_enabled": true, "__prefab": { - "__id__": 135 + "__id__": 147 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -3350,11 +3655,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 124 + "__id__": 136 }, "_enabled": true, "__prefab": { - "__id__": 138 + "__id__": 150 }, "_contentSize": { "__type__": "cc.Size", @@ -3378,11 +3683,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 124 + "__id__": 136 }, "_enabled": false, "__prefab": { - "__id__": 140 + "__id__": 152 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -3423,11 +3728,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 124 + "__id__": 136 }, "_enabled": true, "__prefab": { - "__id__": 142 + "__id__": 154 }, "bounceDuration": 0.23, "brake": 0.75, @@ -3438,7 +3743,7 @@ "cancelInnerEvents": true, "scrollEvents": [], "_content": { - "__id__": 126 + "__id__": 138 }, "_horizontalScrollBar": null, "_verticalScrollBar": null, @@ -3470,30 +3775,30 @@ "__id__": 1 }, "_children": [ - { - "__id__": 145 - }, - { - "__id__": 151 - }, { "__id__": 157 + }, + { + "__id__": 163 + }, + { + "__id__": 169 } ], "_active": true, "_components": [ { - "__id__": 169 + "__id__": 181 }, { - "__id__": 171 + "__id__": 183 }, { - "__id__": 173 + "__id__": 185 } ], "_prefab": { - "__id__": 175 + "__id__": 187 }, "_lpos": { "__type__": "cc.Vec3", @@ -3530,20 +3835,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 144 + "__id__": 156 }, "_children": [], "_active": true, "_components": [ { - "__id__": 146 + "__id__": 158 }, { - "__id__": 148 + "__id__": 160 } ], "_prefab": { - "__id__": 150 + "__id__": 162 }, "_lpos": { "__type__": "cc.Vec3", @@ -3580,11 +3885,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 145 + "__id__": 157 }, "_enabled": true, "__prefab": { - "__id__": 147 + "__id__": 159 }, "_contentSize": { "__type__": "cc.Size", @@ -3608,11 +3913,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 145 + "__id__": 157 }, "_enabled": true, "__prefab": { - "__id__": 149 + "__id__": 161 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -3663,20 +3968,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 144 + "__id__": 156 }, "_children": [], "_active": true, "_components": [ { - "__id__": 152 + "__id__": 164 }, { - "__id__": 154 + "__id__": 166 } ], "_prefab": { - "__id__": 156 + "__id__": 168 }, "_lpos": { "__type__": "cc.Vec3", @@ -3713,11 +4018,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 151 + "__id__": 163 }, "_enabled": true, "__prefab": { - "__id__": 153 + "__id__": 165 }, "_contentSize": { "__type__": "cc.Size", @@ -3741,11 +4046,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 151 + "__id__": 163 }, "_enabled": true, "__prefab": { - "__id__": 155 + "__id__": 167 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -3825,24 +4130,24 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 144 + "__id__": 156 }, "_children": [ { - "__id__": 158 + "__id__": 170 } ], "_active": true, "_components": [ { - "__id__": 164 + "__id__": 176 }, { - "__id__": 166 + "__id__": 178 } ], "_prefab": { - "__id__": 168 + "__id__": 180 }, "_lpos": { "__type__": "cc.Vec3", @@ -3879,20 +4184,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 157 + "__id__": 169 }, "_children": [], "_active": true, "_components": [ { - "__id__": 159 + "__id__": 171 }, { - "__id__": 161 + "__id__": 173 } ], "_prefab": { - "__id__": 163 + "__id__": 175 }, "_lpos": { "__type__": "cc.Vec3", @@ -3929,11 +4234,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 158 + "__id__": 170 }, "_enabled": true, "__prefab": { - "__id__": 160 + "__id__": 172 }, "_contentSize": { "__type__": "cc.Size", @@ -3957,11 +4262,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 158 + "__id__": 170 }, "_enabled": true, "__prefab": { - "__id__": 162 + "__id__": 174 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -4015,11 +4320,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 157 + "__id__": 169 }, "_enabled": true, "__prefab": { - "__id__": 165 + "__id__": 177 }, "_contentSize": { "__type__": "cc.Size", @@ -4043,11 +4348,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 157 + "__id__": 169 }, "_enabled": true, "__prefab": { - "__id__": 167 + "__id__": 179 }, "clickEvents": [], "_interactable": true, @@ -4090,12 +4395,12 @@ "_duration": 0.1, "_zoomScale": 1.2, "_target": { - "__id__": 157 + "__id__": 169 }, "checkEvents": [], "_isChecked": true, "_checkMark": { - "__id__": 161 + "__id__": 173 }, "_id": "" }, @@ -4122,11 +4427,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 144 + "__id__": 156 }, "_enabled": true, "__prefab": { - "__id__": 170 + "__id__": 182 }, "_contentSize": { "__type__": "cc.Size", @@ -4150,11 +4455,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 144 + "__id__": 156 }, "_enabled": true, "__prefab": { - "__id__": 172 + "__id__": 184 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -4195,11 +4500,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 144 + "__id__": 156 }, "_enabled": true, "__prefab": { - "__id__": 174 + "__id__": 186 }, "clickEvents": [], "_interactable": true, @@ -4268,34 +4573,34 @@ }, "_enabled": true, "__prefab": { - "__id__": 177 + "__id__": 189 }, "backBtn": { "__id__": 10 }, "scrollView": { - "__id__": 124 + "__id__": 136 }, "listContent": { - "__id__": 126 + "__id__": 138 }, "listTemplate": { - "__id__": 144 + "__id__": 156 }, "selectedLabel": { - "__id__": 37 + "__id__": 49 }, "completeBtn": { - "__id__": 52 + "__id__": 64 }, "previewBtn": { - "__id__": 72 + "__id__": 84 }, "shareTitleEditBox": { - "__id__": 98 + "__id__": 110 }, "dataBtn": { - "__id__": 20 + "__id__": 34 }, "_id": "" }, @@ -4313,7 +4618,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 179 + "__id__": 191 }, "_contentSize": { "__type__": "cc.Size", @@ -4341,7 +4646,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 181 + "__id__": 193 }, "_alignFlags": 45, "_target": null, diff --git a/assets/prefabs/PassModal.ts b/assets/prefabs/PassModal.ts index 6a3dbd7..c051e7c 100644 --- a/assets/prefabs/PassModal.ts +++ b/assets/prefabs/PassModal.ts @@ -1,4 +1,4 @@ -import { _decorator, Node, Label, AudioClip, AudioSource, view, UITransform, Size, ProgressBar } from 'cc'; +import { _decorator, Node, Label, AudioClip, AudioSource, view, UITransform, Size, ProgressBar, tween, Tween } from 'cc'; import { BaseModal } from 'db://assets/scripts/core/BaseModal'; import { WxSDK } from 'db://assets/scripts/utils/WxSDK'; const { ccclass, property } = _decorator; @@ -22,6 +22,12 @@ export interface PassModalTitleInfo { interface PassModalParams { levelIndex?: number; titleInfo?: PassModalTitleInfo; + /** + * 通关前的称号信息。传入后,本次显示会把进度条从该起点动画到 titleInfo 的终点; + * 起点与终点 titleText 不同则分两段(先填满当前等级,再切换到新等级后填到目标进度)。 + * 分享模式等无本地进度变化的场景不要传。 + */ + previousTitleInfo?: PassModalTitleInfo; } /** @@ -57,22 +63,40 @@ export class PassModal extends BaseModal { @property(AudioClip) successAudio: AudioClip | null = null; + /** 进度条动画起始前的等待时长(秒),等弹窗开场动画稳定后再开始 */ + private static readonly PROGRESS_ANIM_START_DELAY = 0.4; + /** 单段进度条填充动画时长(秒) */ + private static readonly PROGRESS_ANIM_SEGMENT_DURATION = 0.6; + /** 跨称号切换时的等级信息刷新停顿(秒),让玩家看清称号变更 */ + private static readonly PROGRESS_ANIM_LEVELUP_PAUSE = 0.12; + /** 回调函数 */ private _callbacks: PassModalCallbacks = {}; /** 缓存的屏幕尺寸 */ private _screenSize: Size | null = null; - /** 称号展示数据 */ + /** 称号展示数据(终态) */ private _titleInfo: PassModalTitleInfo = { titleText: '冷场小白1级', nextTitleProgress: 0, progressText: '还差3题获得冷场小白2级' }; + /** 动画起点。为 null 表示不做进度动画,直接展示终态 */ + private _previousTitleInfo: PassModalTitleInfo | null = null; + + /** 进度动画所绑定的对象,用于 Tween.stopAllByTarget */ + private readonly _progressTweenTarget: { progress: number } = { progress: 0 }; + setParams(params: PassModalParams): void { super.setParams(params); + // previousTitleInfo 可以显式传 null 来禁用动画;undefined 表示"保持已有状态" + if (params && 'previousTitleInfo' in params) { + this._previousTitleInfo = params.previousTitleInfo ?? null; + } + if (params?.titleInfo) { this.setTitleInfo(params.titleInfo); } @@ -93,7 +117,7 @@ export class PassModal extends BaseModal { ...this._titleInfo, ...titleInfo }; - this._updateTitleInfo(); + this._refreshTitleView(); } /** @@ -110,14 +134,24 @@ export class PassModal extends BaseModal { onViewShow(): void { super.onViewShow(); this._updateWidget(); - this._updateTitleInfo(); + this._refreshTitleView(); this._playSuccessSound(); + this._playProgressAnimation(); + } + + /** + * 页面隐藏时调用 + */ + onViewHide(): void { + super.onViewHide(); + this._stopProgressAnimation(); } /** * 页面销毁时调用 */ onViewDestroy(): void { + this._stopProgressAnimation(); this._unbindButtonEvents(); } @@ -177,20 +211,151 @@ export class PassModal extends BaseModal { } /** - * 更新称号体系核心变量 + * 用当前 _titleInfo 刷新视图(称号、进度条、进度文案) + * 进度条动画运行时,会由动画控制进度值,这里仍然把进度写为终态 + * —— _playProgressAnimation 会在动画开始前覆盖为起点。 */ - private _updateTitleInfo(): void { - if (this.titleLevelLabel && this._titleInfo.titleText !== undefined) { - this.titleLevelLabel.string = this._titleInfo.titleText; + private _refreshTitleView(): void { + this._applyTitleText(this._titleInfo.titleText); + this._applyProgressText(this._titleInfo.progressText); + this._applyProgressValue(this._titleInfo.nextTitleProgress); + } + + private _applyTitleText(text: string | undefined): void { + if (this.titleLevelLabel && text !== undefined) { + this.titleLevelLabel.string = text; + } + } + + private _applyProgressText(text: string | undefined): void { + if (this.progressLabel && text !== undefined) { + this.progressLabel.string = text; + } + } + + private _applyProgressValue(progress: number | undefined): void { + if (this.titleProgressBar && progress !== undefined) { + this.titleProgressBar.progress = this._normalizeProgress(progress); + } + } + + /** + * 根据 _previousTitleInfo → _titleInfo 驱动进度条过渡动画 + * + * 三种情况: + * 1. 无起点信息或起点/终点相同:不播动画 + * 2. 同称号下涨进度:一段 tween + * 3. 跨称号:先把旧称号填到 1.0,然后切换称号文字、进度回 0,再 tween 到终点进度 + */ + private _playProgressAnimation(): void { + const prev = this._previousTitleInfo; + // 动画是一次性的,播放前消费掉,避免弹窗被复用时重复播 + this._previousTitleInfo = null; + + if (!this.titleProgressBar || !prev) { + return; } - if (this.titleProgressBar && this._titleInfo.nextTitleProgress !== undefined) { - this.titleProgressBar.progress = this._normalizeProgress(this._titleInfo.nextTitleProgress); + const startProgress = prev.nextTitleProgress; + const endProgress = this._titleInfo.nextTitleProgress; + if (startProgress === undefined || endProgress === undefined) { + return; } - if (this.progressLabel && this._titleInfo.progressText !== undefined) { - this.progressLabel.string = this._titleInfo.progressText; + const isSameTitle = prev.titleText === undefined + || this._titleInfo.titleText === undefined + || prev.titleText === this._titleInfo.titleText; + + // 同称号且起止相同,没必要播动画 + if (isSameTitle && Math.abs(startProgress - endProgress) < 1e-4) { + return; } + + this._stopProgressAnimation(); + + if (isSameTitle) { + // 先展示起点,避免 _refreshTitleView 已把条填到终态 + this._applyProgressValue(startProgress); + this._runProgressTween(startProgress, endProgress, PassModal.PROGRESS_ANIM_START_DELAY); + return; + } + + // 跨称号:先让旧称号文字和起点进度出现在屏上 + this._applyTitleText(prev.titleText); + this._applyProgressText(prev.progressText); + this._applyProgressValue(startProgress); + + const self = this; + const tweenTarget = this._progressTweenTarget; + // raw 值保留 0~1;下发时经 _normalizeProgress + tweenTarget.progress = Math.max(0, Math.min(1, startProgress)); + const clampedEnd = Math.max(0, Math.min(1, endProgress)); + + const onUpdate = () => { + if (self.titleProgressBar?.isValid) { + self.titleProgressBar.progress = self._normalizeProgress(tweenTarget.progress); + } + }; + + tween(tweenTarget) + .delay(PassModal.PROGRESS_ANIM_START_DELAY) + .to( + PassModal.PROGRESS_ANIM_SEGMENT_DURATION, + { progress: 1 }, + { easing: 'sineOut', onUpdate } + ) + .call(() => { + // 切到新称号。progressText/titleText 都切到终态;进度值从 0 开始 + self._applyTitleText(self._titleInfo.titleText); + self._applyProgressText(self._titleInfo.progressText); + tweenTarget.progress = 0; + if (self.titleProgressBar?.isValid) { + self.titleProgressBar.progress = self._normalizeProgress(0); + } + }) + .delay(PassModal.PROGRESS_ANIM_LEVELUP_PAUSE) + .to( + PassModal.PROGRESS_ANIM_SEGMENT_DURATION, + { progress: clampedEnd }, + { easing: 'sineOut', onUpdate } + ) + .start(); + } + + private _runProgressTween(from: number, to: number, delay: number): void { + if (!this.titleProgressBar) { + return; + } + + const tweenTarget = this._progressTweenTarget; + // raw 值保留 0~1 区间,onUpdate 里经 _normalizeProgress 再下发,避免畸变区段 + tweenTarget.progress = Math.max(0, Math.min(1, from)); + this.titleProgressBar.progress = this._normalizeProgress(from); + + const self = this; + const chain = tween(tweenTarget); + if (delay > 0) { + chain.delay(delay); + } + + chain + .to( + PassModal.PROGRESS_ANIM_SEGMENT_DURATION, + { progress: Math.max(0, Math.min(1, to)) }, + { + easing: 'sineOut', + onUpdate: () => { + if (self.titleProgressBar?.isValid) { + self.titleProgressBar.progress = self._normalizeProgress(tweenTarget.progress); + } + } + } + ) + .start(); + } + + private _stopProgressAnimation(): void { + Tween.stopAllByTarget(this._progressTweenTarget); } /** diff --git a/assets/resources/images/FlatIcon/flatIconBack.png b/assets/resources/images/FlatIcon/flatIconBack.png new file mode 100644 index 0000000..e82977e Binary files /dev/null and b/assets/resources/images/FlatIcon/flatIconBack.png differ diff --git a/assets/resources/images/FlatIcon/flatIconBack.png.meta b/assets/resources/images/FlatIcon/flatIconBack.png.meta new file mode 100644 index 0000000..08468bd --- /dev/null +++ b/assets/resources/images/FlatIcon/flatIconBack.png.meta @@ -0,0 +1,134 @@ +{ + "ver": "1.0.27", + "importer": "image", + "imported": true, + "uuid": "568a4811-9616-47c0-a961-bb2ad2854cdb", + "files": [ + ".json", + ".png" + ], + "subMetas": { + "6c48a": { + "importer": "texture", + "uuid": "568a4811-9616-47c0-a961-bb2ad2854cdb@6c48a", + "displayName": "flatIconBack", + "id": "6c48a", + "name": "texture", + "userData": { + "wrapModeS": "clamp-to-edge", + "wrapModeT": "clamp-to-edge", + "imageUuidOrDatabaseUri": "568a4811-9616-47c0-a961-bb2ad2854cdb", + "isUuid": true, + "visible": false, + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "anisotropy": 0 + }, + "ver": "1.0.22", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "f9941": { + "importer": "sprite-frame", + "uuid": "568a4811-9616-47c0-a961-bb2ad2854cdb@f9941", + "displayName": "flatIconBack", + "id": "f9941", + "name": "spriteFrame", + "userData": { + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0.5, + "trimX": 20, + "trimY": 56, + "width": 472, + "height": 399, + "rawWidth": 512, + "rawHeight": 512, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "packable": true, + "pixelsToUnit": 100, + "pivotX": 0.5, + "pivotY": 0.5, + "meshType": 0, + "vertices": { + "rawPosition": [ + -236, + -199.5, + 0, + 236, + -199.5, + 0, + -236, + 199.5, + 0, + 236, + 199.5, + 0 + ], + "indexes": [ + 0, + 1, + 2, + 2, + 1, + 3 + ], + "uv": [ + 20, + 456, + 492, + 456, + 20, + 57, + 492, + 57 + ], + "nuv": [ + 0.0390625, + 0.111328125, + 0.9609375, + 0.111328125, + 0.0390625, + 0.890625, + 0.9609375, + 0.890625 + ], + "minPos": [ + -236, + -199.5, + 0 + ], + "maxPos": [ + 236, + 199.5, + 0 + ] + }, + "isUuid": true, + "imageUuidOrDatabaseUri": "568a4811-9616-47c0-a961-bb2ad2854cdb@6c48a", + "atlasUuid": "", + "trimType": "auto" + }, + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + } + }, + "userData": { + "type": "sprite-frame", + "fixAlphaTransparencyArtifacts": false, + "hasAlpha": true, + "redirect": "568a4811-9616-47c0-a961-bb2ad2854cdb@6c48a" + } +} diff --git a/assets/resources/images/pageLevel/ButtonYellow.png.meta b/assets/resources/images/pageLevel/ButtonYellow.png.meta index 8ad3020..197cb5f 100644 --- a/assets/resources/images/pageLevel/ButtonYellow.png.meta +++ b/assets/resources/images/pageLevel/ButtonYellow.png.meta @@ -51,8 +51,8 @@ "rawHeight": 235, "borderTop": 0, "borderBottom": 0, - "borderLeft": 0, - "borderRight": 0, + "borderLeft": 120, + "borderRight": 120, "packable": true, "pixelsToUnit": 100, "pivotX": 0.5,