| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import { _decorator, ccenum, Component, Enum, Node, Sprite } from 'cc';
- import { aa } from '../aa';
- const { ccclass, property } = _decorator;
- enum MusicType{
- music,
- sound,
- vibrate,
- }
- @ccclass('MusicBar')
- export class MusicBar extends Component {
- @property({ type: Enum(MusicType) })
- readonly musicType:MusicType
- @property(Node)
- openBtn:Node
- @property(Node)
- closeBtn:Node
- protected onEnable(): void {
- this.openBtn?.on(Node.EventType.TOUCH_END,this.clickOpen,this)
- this.closeBtn?.on(Node.EventType.TOUCH_END,this.clickClose,this)
- if(this.musicType ==MusicType.music ){
- this.flash(aa.audio.switchMusic)
- }
- if(this.musicType ==MusicType.sound ){
- this.flash(aa.audio.switchEffect)
- }
- if(this.musicType ==MusicType.vibrate ){
-
- this.flash(aa.audio.switch_vibrate)
- }
- }
- clickSwich(boolean){
- aa.audio.playOneShot("audios/clickUI")
- this.closeBtn.active =boolean
- this.openBtn.active =!boolean
- if(this.musicType ==MusicType.music ){
- aa.audio.switchMusic = !boolean
- if(!boolean){
- aa.audio.replay_music()
- }
- }
- if(this.musicType ==MusicType.sound ){
- aa.audio.switchEffect = !boolean
- }
- if(this.musicType ==MusicType.vibrate ){
- aa.audio.switch_vibrate = !boolean
- }
- aa.audio.save()
- }
- clickOpen(){
- this.clickSwich(true)
- }
- clickClose(){
- this.clickSwich(false)
- }
- flash(open){
- this.openBtn.active = open
- this.closeBtn.active = !open
- }
-
-
- }
|