cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.node.on('touchstart',this.onTouchStart,this)
    },

    onTouchStart () {
        this.playAudio();
    },

    playAudio(){
        GameData.audioCount++;
		let url = GameData.scene.data.questionList[GameData.questionIndex].audio;
		cc.assetManager.loadRemote(url, null, (err, clip) => {
			if (err) {
				console.log(err)
				return;
			}
			let id = cc.audioEngine.play(clip, false, 1);
			cc.audioEngine.setFinishCallback(id, () => {
				GameData.audioCount--;
			})
		});
    },
    // update (dt) {},
});
