70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
/******************************************************************
|
|
* Copyright(C) 2019 - 2020 Nx Studio
|
|
*
|
|
* NX UI插件 -- 常驻音频缓存&&控制
|
|
*
|
|
* 2023.07.88
|
|
******************************************************************/
|
|
|
|
cc.Class( {
|
|
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
|
|
// 通用音效
|
|
clipBtnClicked: { default: null, type: cc.AudioClip, displayName: "按钮点击音" },
|
|
|
|
},
|
|
|
|
// 编辑器特性
|
|
editor: {
|
|
|
|
// 允许当前组件在编辑器模式下运行
|
|
executeInEditMode: false,
|
|
|
|
// requireComponent 参数用来指定当前组件的依赖组件
|
|
requireComponent: null,
|
|
|
|
// 当本组件添加到节点上后,禁止同类型(含子类)的组件再添加到同一个节点,防止逻辑发生冲突
|
|
disallowMultiple: true,
|
|
|
|
// menu 用来将当前组件添加到组件菜单中,方便用户查找
|
|
menu: "扩充/audios 常驻音频控制",
|
|
|
|
},
|
|
|
|
// 载入
|
|
onLoad: function() {
|
|
|
|
// 全局支持
|
|
if( nx.audioHelper ) {
|
|
nx.error( "$Helper:全局音频辅助为单例!" );
|
|
return;
|
|
}
|
|
nx.audioHelper = this;
|
|
},
|
|
|
|
// 销毁
|
|
onDestroy: function() {
|
|
|
|
if( window.nx ){
|
|
// 全局支持
|
|
nx.audioHelper = null;
|
|
}
|
|
|
|
},
|
|
|
|
// ========================================================
|
|
// 音效辅助
|
|
// ========================================================
|
|
|
|
// 按钮点击
|
|
sfxBtnClicked: function() {
|
|
if( this.clipBtnClicked ) {
|
|
nx.audio.playSFX( this.clipBtnClicked, false );
|
|
}
|
|
},
|
|
|
|
} );
|