Laya UI点击播放音效脚本
程序员文章站
2022-05-05 12:29:44
...
import Script = Laya.Script;
import SoundManager = Laya.SoundManager;
export default class AudioSourceScript extends Script {
/** @prop {name: audioClip, tips:"音效地址",type:string,accept:res} */
audioClip:string = "";
constructor() { super(); }
onClick(): void {
if(this.audioClip == "") {
console.warn(`[AudioSourceScript].onClick(): ${this.owner.name} 音效资源为空! `);
return;
}
SoundManager.playSound(this.audioClip,1);
}
}
推荐阅读