// Created by carolsail import UIbase from '../utils/UIbase'; import LocalData from '../manager/LocalData'; import PrefabUtil from '../utils/manager/PrefabUtil'; import AudioMgr from '../manager/AudioMgr'; import AudioPath from '../datas/AudioPath'; import GameUI from './GameUI'; import HomeUI from './HomeUI'; import Plat from '../utils/Palt'; const { ccclass, property } = cc._decorator; @ccclass export default class PauseUI extends UIbase { private static _inst:PauseUI; public static get inst() { if(this._inst==null || this._inst.node==null) { let v=cc.instantiate(PrefabUtil.get("PauseUI")); this._inst=v.getComponent(PauseUI); } return this._inst; } @property(cc.Sprite) musicSprite: cc.Sprite = null @property(cc.Sprite) soundSprite: cc.Sprite = null // @property(cc.Node) // btnClose: cc.Node = null @property(cc.SpriteFrame) openFrame: cc.SpriteFrame = null @property(cc.SpriteFrame) closeFrame: cc.SpriteFrame = null start() { this.updateMusic(); this.updateSound(); } protected onShow(): void { Plat.showBanner() } protected onHide(): void { Plat.hideBanner() } onClickClose() { AudioMgr.playSound(AudioPath.CLICK) this.hideUI(); } onClickSound() { AudioMgr.playSound(AudioPath.CLICK) LocalData.yx = !LocalData.yx this.updateSound() } onClickMusic() { AudioMgr.playSound(AudioPath.CLICK) LocalData.yy = !LocalData.yy if ( LocalData.yy==true) { AudioMgr.playBgm(); } else { AudioMgr.stopBgm(); } this.updateMusic() } updateMusic() { this.musicSprite.spriteFrame = LocalData.yy==true?this.openFrame:this.closeFrame } updateSound() { this.soundSprite.spriteFrame = LocalData.yx==true?this.openFrame:this.closeFrame } onClickHome() { this.hideUI(); HomeUI.inst.showUI(); } onClickResume() { GameUI.inst.is_game_pause=false; this.hideUI(); } }