import { GameMng } from "../GameMng"; import AudioMng from "./AudioMng"; import { UIButton } from "./UIButton"; import GameData from "./GameData"; import { Sprite,Component,_decorator } from "cc"; const {ccclass, property} = _decorator; @ccclass export default class ButtonMusic extends Component { @property(Sprite) offSp: Sprite = null; start () { this.refreshUI(); UIButton.BindClick(this.node,()=>{ if(AudioMng.Instance.bgmOn) { GameData.SetCustomData("BgmOn", 0); AudioMng.Instance.StopBGM(); } else{ GameData.SetCustomData("BgmOn", 1); AudioMng.Instance.PlayBGM(GameMng.Instance.gamebgm); } this.refreshUI(); },this); } refreshUI(){ this.offSp.node.active=!AudioMng.Instance.bgmOn; } }