// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        audio: {
            default: null,
            type: cc.AudioClip
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        // this.current = cc.audioEngine.play(this.audio, true, 1);
        let audioId = cc.audioEngine.playMusic(this.audio, true);
        cc.audioEngine.setVolume(audioId, 0.5);
    },

    onDestroy: function () {
        cc.audioEngine.stop(this.current);
    },

    start () {

    },

    // update (dt) {},
});
