feat(ui): 添加加载界面并集成到胜利场景中

在胜利场景中添加新的加载界面元素,包括:
1. 创建loading.prefab资源文件
2. 在MissionHomeComp中处理MissionStart事件
3. 在VictoryComp中控制loading节点的显示逻辑
4. 更新victory.prefab结构以包含loading节点
This commit is contained in:
walkpan
2026-01-03 20:21:00 +08:00
parent 2d79e9d064
commit 1c36718876
5 changed files with 766 additions and 12 deletions

View File

@@ -0,0 +1,506 @@
[
{
"__type__": "cc.Prefab",
"_name": "loading",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "loading",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 10
}
],
"_active": false,
"_components": [
{
"__id__": 22
},
{
"__id__": 24
},
{
"__id__": 26
}
],
"_prefab": {
"__id__": 28
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 640,
"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.Node",
"_name": "bg1",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 5
},
{
"__id__": 7
}
],
"_prefab": {
"__id__": 9
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -650,
"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__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 4
},
"_contentSize": {
"__type__": "cc.Size",
"width": 740,
"height": 1300
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "9d1lAxVeZJsI6hfgmn16l0"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 6
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "cb93c900-b440-4571-91d1-7da1636e3d73@2ef13",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": {
"__uuid__": "cb93c900-b440-4571-91d1-7da1636e3d73",
"__expectedType__": "cc.SpriteAtlas"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b1XGKSWqlF/Yf7yyv3neih"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 8
},
"_alignFlags": 45,
"_target": null,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 20,
"_originalHeight": 20,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "3djIeuqDpPZbBlEA+Wmqzv"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "bblW/bQxdMP5lraMnWpYVC",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_prefab": {
"__id__": 11
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "9cc71d8c-192a-4234-8204-352f42b95c65",
"__expectedType__": "cc.Prefab"
},
"fileId": "a0daVw8DRLi6ToMaTA0VS2",
"instance": {
"__id__": 12
},
"targetOverrides": null
},
{
"__type__": "cc.PrefabInstance",
"fileId": "7eQv5ppk1Hpr0USxE6y7Ww",
"prefabRootNode": {
"__id__": 1
},
"mountedChildren": [],
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 13
},
{
"__id__": 15
},
{
"__id__": 16
},
{
"__id__": 17
},
{
"__id__": 18
},
{
"__id__": 20
}
],
"removedComponents": []
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 14
},
"propertyPath": [
"_name"
],
"value": "netinstable"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"a0daVw8DRLi6ToMaTA0VS2"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 14
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 14
},
"propertyPath": [
"_lrot"
],
"value": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 14
},
"propertyPath": [
"_euler"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 19
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 740,
"height": 1300
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"77N2cid5pKDpXplRH/AWEU"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 21
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 740,
"height": 1300
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"fbb9ezFuVDaKU7Tqqncexy"
]
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 23
},
"_contentSize": {
"__type__": "cc.Size",
"width": 740,
"height": 1300
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "5f/wlde7xDGqRmc4TaTJHZ"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 25
},
"_alignFlags": 45,
"_target": null,
"_left": -10,
"_right": -10,
"_top": -10,
"_bottom": -10,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 100,
"_originalHeight": 100,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "cenzbCwmZE56xRaac3dhPZ"
},
{
"__type__": "cc.BlockInputEvents",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 27
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "91NOQbZ0pEZpdUsC/eNF62"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "5a9CMsVQhKP5Y+UJfTKPbx",
"targetOverrides": null,
"nestedPrefabInstanceRoots": [
{
"__id__": 10
}
]
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "26bff847-cd29-48a5-bbfa-c3e2dbda688d",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "loading"
}
}

View File

@@ -26,28 +26,31 @@
},
{
"__id__": 36
},
{
"__id__": 89
}
],
"_active": true,
"_components": [
{
"__id__": 89
"__id__": 106
},
{
"__id__": 91
"__id__": 108
},
{
"__id__": 93
"__id__": 110
},
{
"__id__": 95
"__id__": 112
},
{
"__id__": 97
"__id__": 114
}
],
"_prefab": {
"__id__": 99
"__id__": 116
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -2172,6 +2175,225 @@
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_prefab": {
"__id__": 90
},
"__editorExtras__": {}
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 89
},
"asset": {
"__uuid__": "26bff847-cd29-48a5-bbfa-c3e2dbda688d",
"__expectedType__": "cc.Prefab"
},
"fileId": "5a9CMsVQhKP5Y+UJfTKPbx",
"instance": {
"__id__": 91
},
"targetOverrides": null
},
{
"__type__": "cc.PrefabInstance",
"fileId": "baAcuO8pBEOJtTY5r2CdgQ",
"prefabRootNode": {
"__id__": 1
},
"mountedChildren": [],
"mountedComponents": [],
"propertyOverrides": [
{
"__id__": 92
},
{
"__id__": 94
},
{
"__id__": 95
},
{
"__id__": 96
},
{
"__id__": 97
},
{
"__id__": 98
},
{
"__id__": 100
},
{
"__id__": 102
},
{
"__id__": 104
}
],
"removedComponents": []
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 93
},
"propertyPath": [
"_name"
],
"value": "loading"
},
{
"__type__": "cc.TargetInfo",
"localID": [
"5a9CMsVQhKP5Y+UJfTKPbx"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 93
},
"propertyPath": [
"_lpos"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 93
},
"propertyPath": [
"_lrot"
],
"value": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 93
},
"propertyPath": [
"_euler"
],
"value": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 93
},
"propertyPath": [
"_active"
],
"value": false
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 99
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 740.0000000000006,
"height": 1300
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"5f/wlde7xDGqRmc4TaTJHZ"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 101
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 740.0000000000006,
"height": 1300
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"9d1lAxVeZJsI6hfgmn16l0"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 103
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 740.0000000000006,
"height": 1300
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"7eQv5ppk1Hpr0USxE6y7Ww",
"77N2cid5pKDpXplRH/AWEU"
]
},
{
"__type__": "CCPropertyOverrideInfo",
"targetInfo": {
"__id__": 105
},
"propertyPath": [
"_contentSize"
],
"value": {
"__type__": "cc.Size",
"width": 740.0000000000006,
"height": 1300
}
},
{
"__type__": "cc.TargetInfo",
"localID": [
"7eQv5ppk1Hpr0USxE6y7Ww",
"fbb9ezFuVDaKU7Tqqncexy"
]
},
{
"__type__": "cc.UITransform",
"_name": "",
@@ -2182,7 +2404,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 90
"__id__": 107
},
"_contentSize": {
"__type__": "cc.Size",
@@ -2210,7 +2432,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 92
"__id__": 109
},
"_id": ""
},
@@ -2228,7 +2450,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 94
"__id__": 111
},
"_alignFlags": 45,
"_target": null,
@@ -2264,7 +2486,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 96
"__id__": 113
},
"_customMaterial": null,
"_srcBlendFactor": 2,
@@ -2306,7 +2528,7 @@
},
"_enabled": true,
"__prefab": {
"__id__": 98
"__id__": 115
},
"_id": ""
},
@@ -2324,6 +2546,11 @@
},
"fileId": "d0FqR3MNdHHKbJYj7BXmc4",
"instance": null,
"targetOverrides": null
"targetOverrides": null,
"nestedPrefabInstanceRoots": [
{
"__id__": 89
}
]
}
]

View File

@@ -14,6 +14,7 @@ const { ccclass, property } = _decorator;
export class MissionHomeComp extends CCComp {
protected onLoad(): void {
this.on(GameEvent.MissionEnd,this.mission_end,this)
this.on(GameEvent.MissionStart,this.mission_start,this)
}
/** 视图层逻辑代码分离演示 */
start() {
@@ -31,6 +32,9 @@ export class MissionHomeComp extends CCComp {
console.log("[MissionHomeComp]=>mission_end")
this.home_active()
}
mission_start(){
this.node.active=false
}
home_active(){
this.uodate_data()
this.node.active=true

View File

@@ -32,11 +32,13 @@ export class VictoryComp extends CCComp {
/** 视图层逻辑代码分离演示 */
protected onLoad(): void {
this.node.getChildByName("loading").active=false
// this.canRevive = true;
// this.reviveCount = 0;
}
onAdded(args: any) {
this.node.getChildByName("loading").active=false
console.log("[VictoryComp] onAdded",args)
if(args.game_data){
this.game_data=args.game_data
@@ -142,8 +144,10 @@ export class VictoryComp extends CCComp {
this.clear_data()
// 确保游戏结束事件被触发,以便重置状态
oops.message.dispatchEvent(GameEvent.MissionEnd)
this.node.getChildByName("loading").active=true
this.scheduleOnce(()=>{
oops.message.dispatchEvent(GameEvent.MissionStart)
this.node.getChildByName("loading").active=false
oops.gui.removeByNode(this.node)
},0.5)
}