// 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: {
        toNext:cc.Node,
        personShow:cc.Node,
        showTime:0,
        audio: {
            default: null,
            type: cc.AudioClip
        },
        // hoooAudio:{
        //     default: null,
        //     type: cc.AudioClip
        // },
        bgMusic:{
            default: null,
            type: cc.AudioClip
        }
    },

    startClick(){
         // this.current = cc.audioEngine.play(this.audio, true, 1);
         let bgMusicAll = cc.audioEngine.playMusic(this.bgMusic, true);
         cc.audioEngine.setVolume(bgMusicAll, 0.5);


        let audioId = cc.audioEngine.playEffect(this.audio, false);
        cc.audioEngine.setVolume(audioId, 1);
        cc.director.loadScene("sence_game");
    },

    onDownLoad(e){
        // $('#btn').on('touchstart', function (e) {
            let audioId = cc.audioEngine.playEffect(this.audio, false);
            cc.audioEngine.setVolume(audioId, 1);
            window.playableSDK.sendEvent('clickDownloadBar', {
                section: 'section2',
                area: 'area3'
            });
            window.playableSDK.openAppStore()


        // })
    },


    // LIFE-CYCLE CALLBACKS:

    onLoad () {
    },


    start () {
        //  场景文本框为 显示5
        this.showTime = 0;
        if (this.showTime >= 0) {
            this.schedule(function () {    // 计时器将每隔 1s 执行一次。
              
                this.textChane();
                if(this.showTime==1){
                    // let audioId = cc.audioEngine.playEffect(this.hoooAudio, false);
                    // cc.audioEngine.setVolume(audioId, 1);
                    this.personShow.active = true
                }   
            }, 1);
        }
                           
    },
    textChane(){
        this.showTime = this.showTime + 1;
    }

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