41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
// Learn cc.Class:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
|
|
// Learn Attribute:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
var wxVoice = require("wxVoice")
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
soundname:"",
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {},
|
|
|
|
|
|
onEnable () {
|
|
var self = this
|
|
cc.loader.loadRes("sounds/"+this.soundname, cc.AudioClip, null, function (err, clip) {
|
|
if (!err&& self.isValid) {
|
|
self.audioID = cc.audioEngine.playEffect(clip, true);
|
|
}
|
|
});
|
|
|
|
},
|
|
onDisable(){
|
|
if(this.audioID){
|
|
cc.audioEngine.stopEffect(this.audioID)
|
|
}
|
|
|
|
}
|
|
|
|
// update (dt) {},
|
|
});
|