import { GameViewType } from "../../main/ViewManage"; import ViewObject from "../../main/ViewObject"; /** * 声音设置 */ const { ccclass, property } = cc._decorator; @ccclass export default class TapSetMusic extends ViewObject { @property(cc.Sprite) mMusicSprite1: cc.Sprite = null;//背景音乐音量 @property(cc.Sprite) mMusicSprite2: cc.Sprite = null;//背景音乐音量 @property(cc.SpriteFrame) mON: cc.SpriteFrame = null; @property(cc.SpriteFrame) mOFF: cc.SpriteFrame = null; @property(cc.Slider) mMusicSlider1: cc.Slider = null;//背景音乐音量 @property(cc.Slider) mMusicSlider2: cc.Slider = null;//效果音乐音量 onLoad() { this.mMusicSlider1.node.on('slide', this.s1Callback, this); this.mMusicSlider2.node.on('slide', this.s2Callback, this); this.flush(); } /** * * @param prev 父界面 */ public show(prev?:ViewObject){ if(prev){ this.prev = prev; this.prev.__close(); } this.main.viewManage.popView1(this.node); if(this.main && this.main.gameHttp){ this.main.gameHttp.pushEvent(this); } } public flush() { let setting = this.main.player.setting; if (setting.music_ON_OFF_1) { this.mMusicSprite1.spriteFrame = this.mON; } else { this.mMusicSprite1.spriteFrame = this.mOFF; } if (setting.music_ON_OFF_2) { this.mMusicSprite2.spriteFrame = this.mON; } else { this.mMusicSprite2.spriteFrame = this.mOFF; } this.mMusicSlider1.progress = setting.music_Slider_1; this.mMusicSlider2.progress = setting.music_Slider_2; } public onclick1() { let setting = this.main.player.setting; setting.music_ON_OFF_1 = !setting.music_ON_OFF_1; this.flush(); if (setting.music_ON_OFF_1) { this.main.resumeMusic(); } else { this.main.pauseMusic(); } this.main.player.saveSetting(); } public conclick2() { let setting = this.main.player.setting; setting.music_ON_OFF_2 = !setting.music_ON_OFF_2; this.flush(); this.main.player.saveSetting(); } public s1Callback(silder: cc.Slider) { let setting = this.main.player.setting; setting.music_Slider_1 = silder.progress; if (this.main.bgmId >= 0) { cc.audioEngine.setMusicVolume(setting.music_Slider_1); } this.main.player.saveSetting(); } public s2Callback(silder: cc.Slider) { let setting = this.main.player.setting; setting.music_Slider_2 = silder.progress; this.main.player.saveSetting(); } public exitLogin() { cc.director.loadScene('hotUpdate') } public openNotice() { this.main.viewManage.loadFunc(GameViewType.tap_set_Ann, (viewObject: ViewObject) => { // let tap_set_Ann:Tap_set_Ann = viewObject as Tap_set_Ann; viewObject.show(this); }); } }