cocos creator基础-(九)cc.AudioSource使用
1: 掌握cc.AudioSource组件的使用; cc.AudioSource
? cc.AudioClip对象 1: 音频剪辑对象,支持的格式有mp3,ogg ? AudioSource代码使用 1: 代码中获得cc.AudioSource组件: cc.Class({ extends: cc.Component,properties: { // foo: { // default: null,// The default value will be used only when the component attaching // to a node for the first time // url: cc.Texture2D,// optional,default is typeof default // serializable: true,default is true // visible: true,default is true // displayName: ‘Foo‘,// optional // readonly: false,default is false // }, // ... // 编辑器来指定 audio: { type: cc.AudioSource,default: null,},// use this for initialization onLoad: function () { // 获得节点,获得节点上的组件 this.audio2 = this.node.getChildByName("audio").getComponent(cc.AudioSource); },start: function() { this.audio2.loop = true; // 循环播放,注意一下位置 this.audio2.mute = false; // 设置静音 console.log(this.audio2.isPlaying); // 是否正在播放 // this.audio.play(); this.audio2.play(); /*this.scheduleOnce(function() { this.audio.stop(); }.bind(this),3);*/ /*this.scheduleOnce(function() { this.audio.pause(); // 暂停 }.bind(this),3); this.scheduleOnce(function() { this.audio.resume(); // 恢复 }.bind(this),6);*/ },// called every frame,uncomment this function to activate update callback // update: function (dt) { // }, }); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |