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 ButtonSound extends Component { @property(Sprite) offSp: Sprite = null; start () { this.refreshUI(); UIButton.BindClick(this.node,()=>{ if(AudioMng.Instance.soundOn) { GameData.SetCustomData("SoundOn", 0); } else{ GameData.SetCustomData("SoundOn", 1); } this.refreshUI(); },this); } refreshUI(){ this.offSp.node.active=!AudioMng.Instance.soundOn; } }