// 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: {
        bgm: {
            default: null,
            type: cc.AudioClip
        },
        a: {
            default: null,
            type: cc.AudioClip
        },
        hei: {
            default: null,
            type: cc.AudioClip
        },
        ha: {
            default: null,
            type: cc.AudioClip
        },
        imwin: {
            default: null,
            type: cc.AudioClip
        },
        kuaidaozhongdian: {
            default: null,
            type: cc.AudioClip
        },
        luoshui: {
            default: null,
            type: cc.AudioClip
        },
        wohuihuilaide: {
            default: null,
            type: cc.AudioClip
        },
        zhecibusuan: {
            default: null,
            type: cc.AudioClip
        },
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        app.bgm = this;
    },

    start () {

        this.myMusic = null;
    },
    stop : function(){
        cc.audioEngine.stopMusic();
    },
    play : function () {
        if (this.myMusic != null) {
            this.stop();
        }

        this.myMusic = cc.audioEngine.playMusic(this.bgm,true);
    },
    //掉下去了
    playa : function () {
        cc.audioEngine.play(this.a,false,1);
    },
    //两步
    playhei : function () {
        cc.audioEngine.play(this.hei,false,0.5);
    },
    // 一步
    playha : function () {
        cc.audioEngine.play(this.ha,false,0.5);
    },
    playimwin : function () {
        cc.audioEngine.play(this.imwin,false,1);
        setTimeout(function () {
            this.stop();
        }.bind(this),700)
    },
    playkuaidaozhongdian : function () {
        cc.audioEngine.play(this.kuaidaozhongdian,false,1);
    },
    playluoshui : function () {
        cc.audioEngine.play(this.luoshui,false,1);
    },
    playwohuihuilaide : function () {
        cc.audioEngine.play(this.wohuihuilaide,false,1);
    },
    playzhecibusuan : function () {
        cc.audioEngine.play(this.zhecibusuan,false,1);
        setTimeout(function () {
            this.stop();
        }.bind(this),700)
    },

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