/**
* Author:W
* 音效组件使用
*/
cc.Class({
extends: cc.Component,
properties: {
audioSource:{
default:null,
type:cc.AudioSource,
}
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
this.playAudio();
setTimeout(function(){
this.pauseAudio();
}.bind(this),10000);
setTimeout(function(){
this.stopAudio();
}.bind(this),25000);
},
playAudio:function()
{
this.audioSource.play();
cc.log("音效播放");
},
pauseAudio:function()
{
this.audioSource.pause();
cc.log("音效暂停");
},
stopAudio:function(){
this.audioSource.stop();
cc.log("音效停止");
}
// update (dt) {},
});
音效组件的使用
最新推荐文章于 2025-03-31 23:14:06 发布