
cc.Class({
    extends: cc.Component,

    properties: {
        kuang:cc.Node,
        jiantou:cc.Node,
        listPrefab:cc.Prefab,
        list_main:cc.Node,
        tishitubiao: cc.Node,  //大红点
        _zongNum:0,
        _count:0,
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        var self = this;
        var seq = cc.repeatForever(cc.sequence(cc.scaleTo(1,1.1),cc.scaleTo(1,1)));
        this.jiantou.runAction(seq);

        if (cc.sys.platform === cc.sys.WECHAT_GAME) {
            sdk.Post(sdk.ip2+"/tuijian/box",{},function(data){
                console.log("左边游戏",data);
                self._zongNum =data.d.length;
                for(let i = 0;i<data.d.length;i++){
                    var listgamePre = cc.instantiate(self.listPrefab);
                    listgamePre.getComponent("listgame").init(data.d[i]);
                    listgamePre.parent = self.list_main;
                }
            })
        }

        //处理更多游戏面板外面的大点红
        cc.game.on("hongdian",function(event){
            console.log("红点问题",event.detail);
            self._count +=event.detail;
            if(self._zongNum ==self._count){
                self.tishitubiao.active =false;
            }
        });
    },

    smooth_out(){
        if(this.node.getChildByName("bg").active == false){
            this.node.getChildByName("bg").active = true;
            var action = cc.moveBy(0.4, 504, 0);
            this.kuang.runAction(action);
            // this.jiantou.stopAllActions();
        }else{
            this.smooth_in();
        }
    },

    smooth_in(){
        this.node.getChildByName("bg").active = false;
        var action = cc.moveBy(0.4, -504, 0);
        this.kuang.runAction(action);
        var seq = cc.repeatForever(cc.sequence(cc.scaleTo(1,1.1),cc.scaleTo(1,1)));
        this.jiantou.runAction(seq);
    },


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