From 7701ae8bbfeadd9125eff65a6b59b3306697da8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?computer=5C=E5=B0=BC=E5=8D=A1?= <203267346@qq.com> Date: Thu, 3 Jul 2025 12:16:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=81=9C=E7=95=8C=E9=9D=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Scene/GameScene.fire | 20 +- assets/Script/Pause.ts | 248 +++++++++++----------- assets/Script/SceneManager.ts | 2 + assets/Script/module/Config/GameConfig.ts | 2 +- assets/Script/setUi.ts | 22 +- 5 files changed, 149 insertions(+), 145 deletions(-) diff --git a/assets/Scene/GameScene.fire b/assets/Scene/GameScene.fire index 06a55c3..7f51273 100644 --- a/assets/Scene/GameScene.fire +++ b/assets/Scene/GameScene.fire @@ -10940,11 +10940,11 @@ { "__type__": "cc.ClickEvent", "target": { - "__id__": 2 + "__id__": 13 }, "component": "", - "_componentId": "80998T1AYNNRZdRxsVvXR65", - "handler": "", + "_componentId": "2234assp7RIvpDgrnqljp2R", + "handler": "homeBtn", "customEventData": "" }, { @@ -11012,7 +11012,7 @@ "__id__": 299 } ], - "_active": true, + "_active": false, "_components": [], "_prefab": null, "_opacity": 255, @@ -15527,11 +15527,11 @@ { "__type__": "cc.ClickEvent", "target": { - "__id__": 13 + "__id__": 2 }, "component": "", - "_componentId": "2234assp7RIvpDgrnqljp2R", - "handler": "homeBtn", + "_componentId": "80998T1AYNNRZdRxsVvXR65", + "handler": "returnHome", "customEventData": "" }, { @@ -17709,11 +17709,11 @@ { "__type__": "cc.ClickEvent", "target": { - "__id__": 2 + "__id__": 13 }, "component": "", - "_componentId": "80998T1AYNNRZdRxsVvXR65", - "handler": "returnHome", + "_componentId": "2234assp7RIvpDgrnqljp2R", + "handler": "homeBtn", "customEventData": "" }, { diff --git a/assets/Script/Pause.ts b/assets/Script/Pause.ts index d5bbca6..eec062a 100644 --- a/assets/Script/Pause.ts +++ b/assets/Script/Pause.ts @@ -1,144 +1,144 @@ -// Learn TypeScript: -// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html -// Learn Attribute: -// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html -// Learn life-cycle callbacks: -// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html +// // Learn TypeScript: +// // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html +// // Learn Attribute: +// // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html +// // Learn life-cycle callbacks: +// // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html -const {ccclass, property} = cc._decorator; +// const {ccclass, property} = cc._decorator; -@ccclass -export default class Pause extends cc.Component { - static _instance: any; - time: number = 0; +// @ccclass +// export default class Pause extends cc.Component { +// static _instance: any; +// time: number = 0; - @property(cc.Node) - music: cc.Node = null; +// @property(cc.Node) +// music: cc.Node = null; - @property(cc.Node) - effect: cc.Node = null; +// @property(cc.Node) +// effect: cc.Node = null; - @property(cc.Node) - vibrate: cc.Node = null; +// @property(cc.Node) +// vibrate: cc.Node = null; - @property(cc.SpriteFrame) - open: cc.SpriteFrame = null; +// @property(cc.SpriteFrame) +// open: cc.SpriteFrame = null; - @property(cc.SpriteFrame) - close: cc.SpriteFrame = null; +// @property(cc.SpriteFrame) +// close: cc.SpriteFrame = null; - // mapInfo: number[][] = []; +// // mapInfo: number[][] = []; - musicState: boolean = true; - effectState: boolean = true; - vibrateState: boolean = true; +// musicState: boolean = true; +// effectState: boolean = true; +// vibrateState: boolean = true; - onLoad () { - if(cc.fx.GameConfig.GM_INFO.musicOpen){ - this.music.getComponent(cc.Sprite).spriteFrame = this.open; - this.music.x = 278; - } - else{ - this.music.getComponent(cc.Sprite).spriteFrame = this.close; - this.music.x = 161; - } - if(cc.fx.GameConfig.GM_INFO.effectOpen){ - this.effect.getComponent(cc.Sprite).spriteFrame = this.open; - this.effect.x = 278; - } - else{ - this.effect.getComponent(cc.Sprite).spriteFrame = this.close; - this.effect.x = 161; - } - if(cc.fx.GameConfig.GM_INFO.vibrateOpen){ - this.vibrate.getComponent(cc.Sprite).spriteFrame = this.open; - this.vibrate.x = 278; - } - else{ - this.vibrate.getComponent(cc.Sprite).spriteFrame = this.close; - this.vibrate.x = 161; - } - this.musicState = cc.fx.GameConfig.GM_INFO.musicOpen; - this.effectState = cc.fx.GameConfig.GM_INFO.effectOpen; - this.vibrateState = cc.fx.GameConfig.GM_INFO.vibrateOpen; - } +// onLoad () { +// if(cc.fx.GameConfig.GM_INFO.musicOpen){ +// this.music.getComponent(cc.Sprite).spriteFrame = this.open; +// this.music.x = 278; +// } +// else{ +// this.music.getComponent(cc.Sprite).spriteFrame = this.close; +// this.music.x = 161; +// } +// if(cc.fx.GameConfig.GM_INFO.effectOpen){ +// this.effect.getComponent(cc.Sprite).spriteFrame = this.open; +// this.effect.x = 278; +// } +// else{ +// this.effect.getComponent(cc.Sprite).spriteFrame = this.close; +// this.effect.x = 161; +// } +// if(cc.fx.GameConfig.GM_INFO.vibrateOpen){ +// this.vibrate.getComponent(cc.Sprite).spriteFrame = this.open; +// this.vibrate.x = 278; +// } +// else{ +// this.vibrate.getComponent(cc.Sprite).spriteFrame = this.close; +// this.vibrate.x = 161; +// } +// this.musicState = cc.fx.GameConfig.GM_INFO.musicOpen; +// this.effectState = cc.fx.GameConfig.GM_INFO.effectOpen; +// this.vibrateState = cc.fx.GameConfig.GM_INFO.vibrateOpen; +// } - start () { - } +// start () { +// } - init(time){ +// init(time){ - } +// } - clickMusic(){ - if(this.musicState){ - this.musicState = false; - cc.fx.GameConfig.GM_INFO.musicOpen = this.musicState; - this.setMusicConfig(); - this.music.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161,this.music.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ - this.music.getComponent(cc.Sprite).spriteFrame = this.close; - }),cc.fadeIn(0.1))) - cc.fx.AudioManager._instance.stopMusic(); - } - else{ - this.musicState = true; - cc.fx.GameConfig.GM_INFO.musicOpen = this.musicState; - this.setMusicConfig(); - this.music.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278,this.music.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ - this.music.getComponent(cc.Sprite).spriteFrame = this.open; - }),cc.fadeIn(0.1))) - cc.fx.AudioManager._instance.playMusicGame(); - } - } +// clickMusic(){ +// if(this.musicState){ +// this.musicState = false; +// cc.fx.GameConfig.GM_INFO.musicOpen = this.musicState; +// this.setMusicConfig(); +// this.music.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161,this.music.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ +// this.music.getComponent(cc.Sprite).spriteFrame = this.close; +// }),cc.fadeIn(0.1))) +// cc.fx.AudioManager._instance.stopMusic(); +// } +// else{ +// this.musicState = true; +// cc.fx.GameConfig.GM_INFO.musicOpen = this.musicState; +// this.setMusicConfig(); +// this.music.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278,this.music.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ +// this.music.getComponent(cc.Sprite).spriteFrame = this.open; +// }),cc.fadeIn(0.1))) +// cc.fx.AudioManager._instance.playMusicGame(); +// } +// } - setMusicConfig(){ - let audioInfo = { - "musicOpen": cc.fx.GameConfig.GM_INFO.musicOpen, //音乐 - "effectOpen": cc.fx.GameConfig.GM_INFO.effectOpen, //音效 - "vibrateOpen": cc.fx.GameConfig.GM_INFO.vibrateOpen, //震动 - } - cc.fx.StorageMessage.setStorage("music",audioInfo); - } +// setMusicConfig(){ +// let audioInfo = { +// "musicOpen": cc.fx.GameConfig.GM_INFO.musicOpen, //音乐 +// "effectOpen": cc.fx.GameConfig.GM_INFO.effectOpen, //音效 +// "vibrateOpen": cc.fx.GameConfig.GM_INFO.vibrateOpen, //震动 +// } +// cc.fx.StorageMessage.setStorage("music",audioInfo); +// } - clickEffect(){ - if(this.effectState){ - this.effectState = false; - cc.fx.GameConfig.GM_INFO.effectOpen = this.effectState; - this.setMusicConfig(); - this.effect.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161,this.effect.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ - this.effect.getComponent(cc.Sprite).spriteFrame = this.close; - }),cc.fadeIn(0.1))) - } - else{ - this.effectState = true; - cc.fx.GameConfig.GM_INFO.effectOpen = this.effectState; - this.setMusicConfig(); - this.effect.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278,this.effect.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ - this.effect.getComponent(cc.Sprite).spriteFrame = this.open; - }),cc.fadeIn(0.1))) - } - } +// clickEffect(){ +// if(this.effectState){ +// this.effectState = false; +// cc.fx.GameConfig.GM_INFO.effectOpen = this.effectState; +// this.setMusicConfig(); +// this.effect.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161,this.effect.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ +// this.effect.getComponent(cc.Sprite).spriteFrame = this.close; +// }),cc.fadeIn(0.1))) +// } +// else{ +// this.effectState = true; +// cc.fx.GameConfig.GM_INFO.effectOpen = this.effectState; +// this.setMusicConfig(); +// this.effect.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278,this.effect.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ +// this.effect.getComponent(cc.Sprite).spriteFrame = this.open; +// }),cc.fadeIn(0.1))) +// } +// } - clickVibrate(){ - if(this.vibrateState){ - this.vibrateState = false; - cc.fx.GameConfig.GM_INFO.vibrateOpen = this.vibrateState; - this.setMusicConfig(); - this.vibrate.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161,this.vibrate.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ - this.vibrate.getComponent(cc.Sprite).spriteFrame = this.close; - }),cc.fadeIn(0.1))) - } - else{ - this.vibrateState = true; - cc.fx.GameConfig.GM_INFO.vibrateOpen = this.vibrateState; - this.setMusicConfig(); - this.vibrate.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278,this.vibrate.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ - this.vibrate.getComponent(cc.Sprite).spriteFrame = this.open; - }),cc.fadeIn(0.1))) - } - } +// clickVibrate(){ +// if(this.vibrateState){ +// this.vibrateState = false; +// cc.fx.GameConfig.GM_INFO.vibrateOpen = this.vibrateState; +// this.setMusicConfig(); +// this.vibrate.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(161,this.vibrate.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ +// this.vibrate.getComponent(cc.Sprite).spriteFrame = this.close; +// }),cc.fadeIn(0.1))) +// } +// else{ +// this.vibrateState = true; +// cc.fx.GameConfig.GM_INFO.vibrateOpen = this.vibrateState; +// this.setMusicConfig(); +// this.vibrate.runAction(cc.sequence(cc.spawn(cc.moveTo(0.05, cc.v2(278,this.vibrate.y)), cc.fadeOut(0.05)),cc.callFunc(()=>{ +// this.vibrate.getComponent(cc.Sprite).spriteFrame = this.open; +// }),cc.fadeIn(0.1))) +// } +// } - // update (dt) {} -} +// // update (dt) {} +// } diff --git a/assets/Script/SceneManager.ts b/assets/Script/SceneManager.ts index 6b409f6..dc66798 100644 --- a/assets/Script/SceneManager.ts +++ b/assets/Script/SceneManager.ts @@ -169,6 +169,7 @@ export default class SceneManager extends cc.Component { returnHome() { if (this.node.getChildByName("Pause").getChildByName("btn").getComponent("btnControl")._touch) { + this.closePause(); if (MapConroler._instance.gameStart == true) { MiniGameSdk.API.showToast("体力值减少"); cc.fx.GameTool.setUserHealth(-1, (data) => { @@ -195,6 +196,7 @@ export default class SceneManager extends cc.Component { } }); + setTimeout(() => { cc.director.loadScene("HomeScene"); }, 1200); diff --git a/assets/Script/module/Config/GameConfig.ts b/assets/Script/module/Config/GameConfig.ts index 976d082..0ef08cb 100644 --- a/assets/Script/module/Config/GameConfig.ts +++ b/assets/Script/module/Config/GameConfig.ts @@ -251,7 +251,7 @@ export class GameConfig { cc.fx.GameConfig.GM_INFO.level = 204; } let name = "Json/level" + (cc.fx.GameConfig.GM_INFO.level+1); - debugger; + // debugger; // //console.log("关卡名称:",name); // name = "Json/level" + 68; // cc.fx.StorageMessage.setStorage("level",cc.fx.GameConfig.GM_INFO.level.toString()); diff --git a/assets/Script/setUi.ts b/assets/Script/setUi.ts index 6de54ff..28adc0c 100644 --- a/assets/Script/setUi.ts +++ b/assets/Script/setUi.ts @@ -29,16 +29,16 @@ export default class setUi extends cc.Component { musicState: boolean = true; effectState: boolean = true; vibrateState: boolean = true; - +private _isSyncing = false; onLoad() { this.musicState = cc.fx.GameConfig.GM_INFO.musicOpen; this.effectState = cc.fx.GameConfig.GM_INFO.effectOpen; this.vibrateState = cc.fx.GameConfig.GM_INFO.vibrateOpen; - console.log("音乐状态", this.musicState); - console.log("音效状态", this.effectState); - console.log("震动状态", this.vibrateState); - this.syncToggleState(); + console.log("音乐状态", cc.fx.GameConfig.GM_INFO.musicOpen); + console.log("音效状态", cc.fx.GameConfig.GM_INFO.effectOpen); + console.log("震动状态", cc.fx.GameConfig.GM_INFO.vibrateOpen); + this.syncToggleState(); } start() { @@ -49,6 +49,7 @@ export default class setUi extends cc.Component { } clickMusic() { + if (this._isSyncing) return; if (this.musicState) { this.musicState = false; cc.fx.GameConfig.GM_INFO.musicOpen = this.musicState; @@ -76,6 +77,7 @@ export default class setUi extends cc.Component { } clickEffect() { + if (this._isSyncing) return; if (this.effectState) { this.effectState = false; cc.fx.GameConfig.GM_INFO.effectOpen = this.effectState; @@ -88,10 +90,10 @@ export default class setUi extends cc.Component { } - console.log("音效状态", this.effectState); } clickVibrate() { + if (this._isSyncing) return; if (this.vibrateState) { this.vibrateState = false; cc.fx.GameConfig.GM_INFO.vibrateOpen = this.vibrateState; @@ -105,12 +107,12 @@ export default class setUi extends cc.Component { } - console.log("震动状态", this.vibrateState); } syncToggleState() { - this.music.getComponent(cc.Toggle).isChecked = this.musicState; - this.effect.getComponent(cc.Toggle).isChecked = this.effectState; - this.vibrate.getComponent(cc.Toggle).isChecked = this.vibrateState; + this._isSyncing = true; + this.music.getComponent(cc.Toggle).isChecked = cc.fx.GameConfig.GM_INFO.musicOpen; + this.effect.getComponent(cc.Toggle).isChecked = cc.fx.GameConfig.GM_INFO.effectOpen; + this.vibrate.getComponent(cc.Toggle).isChecked = cc.fx.GameConfig.GM_INFO.vibrateOpen; } //关闭ui