feat: 支持失败弹窗
This commit is contained in:
BIN
assets/bundle1/images/FailedDialog.png
Normal file
BIN
assets/bundle1/images/FailedDialog.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
134
assets/bundle1/images/FailedDialog.png.meta
Normal file
134
assets/bundle1/images/FailedDialog.png.meta
Normal file
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "7f9ff6b4-469e-4cef-8422-8f8f93399f82",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "7f9ff6b4-469e-4cef-8422-8f8f93399f82@6c48a",
|
||||
"displayName": "FailedDialog",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "7f9ff6b4-469e-4cef-8422-8f8f93399f82",
|
||||
"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": "7f9ff6b4-469e-4cef-8422-8f8f93399f82@f9941",
|
||||
"displayName": "FailedDialog",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 27,
|
||||
"offsetY": 105,
|
||||
"trimX": 132,
|
||||
"trimY": 260,
|
||||
"width": 540,
|
||||
"height": 604,
|
||||
"rawWidth": 750,
|
||||
"rawHeight": 1334,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-270,
|
||||
-302,
|
||||
0,
|
||||
270,
|
||||
-302,
|
||||
0,
|
||||
-270,
|
||||
302,
|
||||
0,
|
||||
270,
|
||||
302,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
132,
|
||||
1074,
|
||||
672,
|
||||
1074,
|
||||
132,
|
||||
470,
|
||||
672,
|
||||
470
|
||||
],
|
||||
"nuv": [
|
||||
0.176,
|
||||
0.3523238380809595,
|
||||
0.896,
|
||||
0.3523238380809595,
|
||||
0.176,
|
||||
0.8050974512743628,
|
||||
0.896,
|
||||
0.8050974512743628
|
||||
],
|
||||
"minPos": [
|
||||
-270,
|
||||
-302,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
270,
|
||||
302,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "7f9ff6b4-469e-4cef-8422-8f8f93399f82@6c48a",
|
||||
"atlasUuid": "",
|
||||
"trimType": "auto"
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "7f9ff6b4-469e-4cef-8422-8f8f93399f82@6c48a"
|
||||
}
|
||||
}
|
||||
BIN
assets/bundle1/images/SuccessDialog.png
Normal file
BIN
assets/bundle1/images/SuccessDialog.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 68 KiB |
134
assets/bundle1/images/SuccessDialog.png.meta
Normal file
134
assets/bundle1/images/SuccessDialog.png.meta
Normal file
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"ver": "1.0.27",
|
||||
"importer": "image",
|
||||
"imported": true,
|
||||
"uuid": "1a8d83b8-2a7c-4237-a143-e993977ee029",
|
||||
"files": [
|
||||
".json",
|
||||
".png"
|
||||
],
|
||||
"subMetas": {
|
||||
"6c48a": {
|
||||
"importer": "texture",
|
||||
"uuid": "1a8d83b8-2a7c-4237-a143-e993977ee029@6c48a",
|
||||
"displayName": "SuccessDialog",
|
||||
"id": "6c48a",
|
||||
"name": "texture",
|
||||
"userData": {
|
||||
"wrapModeS": "clamp-to-edge",
|
||||
"wrapModeT": "clamp-to-edge",
|
||||
"imageUuidOrDatabaseUri": "1a8d83b8-2a7c-4237-a143-e993977ee029",
|
||||
"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": "1a8d83b8-2a7c-4237-a143-e993977ee029@f9941",
|
||||
"displayName": "SuccessDialog",
|
||||
"id": "f9941",
|
||||
"name": "spriteFrame",
|
||||
"userData": {
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 26.5,
|
||||
"offsetY": 102,
|
||||
"trimX": 128,
|
||||
"trimY": 266,
|
||||
"width": 547,
|
||||
"height": 598,
|
||||
"rawWidth": 750,
|
||||
"rawHeight": 1334,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"packable": true,
|
||||
"pixelsToUnit": 100,
|
||||
"pivotX": 0.5,
|
||||
"pivotY": 0.5,
|
||||
"meshType": 0,
|
||||
"vertices": {
|
||||
"rawPosition": [
|
||||
-273.5,
|
||||
-299,
|
||||
0,
|
||||
273.5,
|
||||
-299,
|
||||
0,
|
||||
-273.5,
|
||||
299,
|
||||
0,
|
||||
273.5,
|
||||
299,
|
||||
0
|
||||
],
|
||||
"indexes": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
2,
|
||||
1,
|
||||
3
|
||||
],
|
||||
"uv": [
|
||||
128,
|
||||
1068,
|
||||
675,
|
||||
1068,
|
||||
128,
|
||||
470,
|
||||
675,
|
||||
470
|
||||
],
|
||||
"nuv": [
|
||||
0.17066666666666666,
|
||||
0.3523238380809595,
|
||||
0.9,
|
||||
0.3523238380809595,
|
||||
0.17066666666666666,
|
||||
0.800599700149925,
|
||||
0.9,
|
||||
0.800599700149925
|
||||
],
|
||||
"minPos": [
|
||||
-273.5,
|
||||
-299,
|
||||
0
|
||||
],
|
||||
"maxPos": [
|
||||
273.5,
|
||||
299,
|
||||
0
|
||||
]
|
||||
},
|
||||
"isUuid": true,
|
||||
"imageUuidOrDatabaseUri": "1a8d83b8-2a7c-4237-a143-e993977ee029@6c48a",
|
||||
"atlasUuid": "",
|
||||
"trimType": "auto"
|
||||
},
|
||||
"ver": "1.0.12",
|
||||
"imported": true,
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {}
|
||||
}
|
||||
},
|
||||
"userData": {
|
||||
"type": "sprite-frame",
|
||||
"hasAlpha": true,
|
||||
"fixAlphaTransparencyArtifacts": false,
|
||||
"redirect": "1a8d83b8-2a7c-4237-a143-e993977ee029@6c48a"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Component, Node, Vec3, input, Input, EventTouch, Camera, view, tween, Animation, Collider2D, Contact2DType, Label, Color, Canvas, UITransform, AudioSource, Sprite } from 'cc';
|
||||
import { _decorator, Component, Node, Vec3, input, Input, EventTouch, Camera, view, tween, Animation, Collider2D, Contact2DType, Label, Color, Canvas, UITransform, AudioSource, Sprite, director } from 'cc';
|
||||
import { TiledMapPathfinder } from './TiledMapPathfinder';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -16,6 +16,9 @@ export class PlayerController extends Component {
|
||||
@property(Node)
|
||||
bonusWuqi: Node | null = null;
|
||||
|
||||
@property(Node)
|
||||
failedDialog: Node | null = null;
|
||||
|
||||
@property(Camera)
|
||||
camera: Camera | null = null; // 主摄像机
|
||||
|
||||
@@ -515,6 +518,11 @@ export class PlayerController extends Component {
|
||||
// 设置游戏结束标志,禁止后续寻路
|
||||
this.isGameOver = true;
|
||||
console.log('游戏结束,禁止寻路');
|
||||
|
||||
// 显示失败弹窗
|
||||
this.scheduleOnce(() => {
|
||||
this.showFailedDialog();
|
||||
}, 1); // 延迟1秒显示失败弹窗,让玩家死亡动画播放完成
|
||||
}
|
||||
|
||||
this.isAttacking = false;
|
||||
@@ -803,4 +811,55 @@ export class PlayerController extends Component {
|
||||
this.pendingPopupHide = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示失败弹窗
|
||||
*/
|
||||
public showFailedDialog() {
|
||||
this.showPopupAtCameraCenter(this.failedDialog, '失败弹窗');
|
||||
this.setupRetryButtonListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置重试按钮监听器
|
||||
*/
|
||||
private setupRetryButtonListener() {
|
||||
if (!this.failedDialog) {
|
||||
console.warn('失败弹窗节点未设置,无法监听重试按钮');
|
||||
return;
|
||||
}
|
||||
|
||||
// 查找Retry按钮节点
|
||||
const retryButton = this.failedDialog.getChildByName('Retry');
|
||||
if (!retryButton) {
|
||||
console.warn('未找到Retry按钮节点');
|
||||
return;
|
||||
}
|
||||
|
||||
// 移除之前的监听器(如果存在)
|
||||
retryButton.off(Node.EventType.TOUCH_END, this.onRetryButtonClick, this);
|
||||
|
||||
// 添加新的监听器
|
||||
retryButton.on(Node.EventType.TOUCH_END, this.onRetryButtonClick, this);
|
||||
console.log('已设置重试按钮监听器');
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试按钮点击事件处理
|
||||
*/
|
||||
private onRetryButtonClick() {
|
||||
console.log('重试按钮被点击,重新加载当前场景');
|
||||
|
||||
// 隐藏失败弹窗
|
||||
if (this.failedDialog) {
|
||||
this.hidePopupWithAnimation(this.failedDialog, '失败弹窗');
|
||||
}
|
||||
|
||||
// 重新加载当前场景
|
||||
this.scheduleOnce(() => {
|
||||
// 使用Cocos Creator的场景管理器重新加载当前场景
|
||||
const sceneName = director.getScene().name;
|
||||
director.loadScene(sceneName);
|
||||
}, 0.3); // 延迟0.3秒,让弹窗消失动画完成
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user