import SoundMgr from "../FrameWork/Mgr/SoundMgr"; import VibrateMgr from "../FrameWork/Mgr/VibrateMgr"; import Common5 from "../Platform/th/Common5"; const { ccclass, property } = cc._decorator; @ccclass export default class SettingPrefab extends cc.Component { protected showNode: cc.Node = null; protected btnClose: cc.Node = null; protected btnMusic: cc.Node = null; protected btnEffect: cc.Node = null; protected btnVibrate:cc.Node = null; // LIFE-CYCLE CALLBACKS: onLoad() { this.showNode = this.node.getChildByName("show").getChildByName("showNode"); this.btnClose = this.node.getChildByName("show").getChildByName("btnClose"); this.btnMusic = this.showNode.getChildByName("btnMusic"); this.btnEffect = this.showNode.getChildByName("btnEffect"); this.btnVibrate = this.showNode.getChildByName("btnVibrate"); Common5.btnRegister_custom(this.btnClose, () => { this.btnCloseFunc(); }) Common5.btnRegister_custom(this.btnMusic, () => { this.btnMusicFunc(); }) Common5.btnRegister_custom(this.btnEffect, () => { this.btnEffectFunc(); }) Common5.btnRegister_custom(this.btnVibrate, () => { this.btnVibrateFunc(); }) this.updateShow(); } start() { } btnCloseFunc() { this.node.removeFromParent(); } btnMusicFunc() { Common5.isNoMusic = !Common5.isNoMusic; SoundMgr.setSoundEnabled_custom(!Common5.isNoMusic); if (Common5.isNoMusic == true) { cc.audioEngine.stopMusic(); } else { Common5.playMusic("bg"); } this.updateShow(); } btnEffectFunc() { Common5.isNoEffect = !Common5.isNoEffect; // VibrateMgr.isEnable_custom = !Common5.isNoZD; this.updateShow(); } btnVibrateFunc() { Common5.isNoZD = !Common5.isNoZD; VibrateMgr.isEnable_custom = !Common5.isNoZD; this.updateShow(); } updateShow() { // this.btnMusic.getComponent(cc.Toggle).isChecked = Common5.isMute; // this.btnEffect.getComponent(cc.Toggle).isChecked = Common5.isNoZD; this.btnMusic.getChildByName("off").active = Common5.isNoMusic; this.btnMusic.getChildByName("on").active = !Common5.isNoMusic; this.btnEffect.getChildByName("off").active = Common5.isNoEffect; this.btnEffect.getChildByName("on").active = !Common5.isNoEffect; this.btnVibrate.getChildByName("off").active = Common5.isNoZD; this.btnVibrate.getChildByName("on").active = !Common5.isNoZD; } // update (dt) {} }