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; } });
背景屏蔽层
最新推荐文章于 2019-04-11 15:42:01 发布