cc.Class({
    extends: cc.Component,

    properties: {
        labWord: cc.Label,

    },

    init(data) {
        this.data = data;
        let string = '';
        for (let i = 0; i < data.optionList.length; i++) {
            string += data.optionList[i].text;
        }
        this.labWord.string = string;
    },
    onLoad() {
        this.node.on('touchstart', this.onTouchStart, this);
    },
    onDestroy() {
        this.node.off('touchstart', this.onTouchStart, this);
    },

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

    playAudio(){
        GameData.audioCount++;
		let url = this.data.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) {},
});
