// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        read: {
            default: null,
            type: cc.AudioClip
        },
        go: {
            default: null,
            type: cc.AudioClip
        },
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        app.readGo = this;
        this.sounds = [];
        this.sounds.push(this.read);
        this.sounds.push(this.go);
    },

    start () {



    },
    readgo: function (callback) {
        this.node.active = true;
        app.bgm.stop();
        let an = this.node.getComponent(cc.Animation);
        an.play();
        cc.audioEngine.play(this.sounds[0],false,1);
        setTimeout(function () {
            cc.audioEngine.play(this.sounds[1],false,1);

            setTimeout(function () {
                this.node.active = false;
                if (callback!=null) {
                    callback();
                }
                app.bgm.play();
            }.bind(this),700)

        }.bind(this),1100)
        },
    // update (dt) {},
});
