123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- // 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();
- }
- }
|