背景屏蔽层

var TopBaseLayer = cc.LayerColor.extend({
    _contentLayer: null,
    _queren:null,
    _showTouchDis:false,
    _callBack: null,
    ctor: function (isTransparent) {
        this._super(cc.color(0, 0, 0, isTransparent ? 0.1 : 200));

        this._contentLayer = new cc.Layer();
        cc.LayerColor.prototype.addChild.call(this, this._contentLayer);

        var self = this;
        cc.eventManager.addListener({
            event: cc.EventListener.TOUCH_ONE_BY_ONE,
            swallowTouches: true,
            onTouchBegan: function (touch, event) {
                return true;
            },
            onTouchEnded: function () {
                if(!self._showTouchDis)
                    return true;
                if(self._callBack){
                    self._callBack();
                }else{
                    //MainScene.removeTopLayers();
                    self.removeFromParent();
                }
                return true;
            }
        }, this);
    },
    addChild: function (child, localZOrder, tag) {
        localZOrder = localZOrder === undefined ? child.getLocalZOrder() : localZOrder;
        tag = tag === undefined ? child.getTag() : tag;
        this._contentLayer.addChild(child, localZOrder, tag);
    },
    removeChild: function (child, cleanup) {
        cleanup = cleanup || false;
        this._contentLayer.removeChild(child, cleanup);
    },
    removeChildByTag: function (tag, cleanup) {
        cleanup = cleanup || false;
        this._contentLayer.removeChildByTag(tag, cleanup);
    },
    removeAllChildren: function (cleanup) {
        cleanup = cleanup || false;
        this._contentLayer.removeAllChildren(cleanup);
    },
    setCallBack: function (callBack) {
        this._callBack = callBack;
    },
    setDis: function (showTouchDis, pos) {
        if(!this._queren){
            var visibleSize = cc.director.getVisibleSize();
            this._queren = new cc.Sprite(res.shangdian_zi_shangcheng_dianjijixu_png);
            this._queren.setPosition(cc.p(visibleSize.width / 2,visibleSize.height / 3));
            if(pos){
                this._queren.setPosition(pos);
            }
            this._queren.runAction(cc.repeatForever(cc.sequence(cc.fadeOut(0.5),cc.fadeIn(0.9))));
            this.addChild(this._queren);
        }
        this._queren.setVisible(showTouchDis);
        this._showTouchDis = showTouchDis;
    }
});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值