北京比较好的网站开发公司,成都网站建设中心,wordpress怎么改变主页字体大小,wordpress 婚恋模板经过一段时间的学习#xff0c;才发现CH5里scrollview的例子很少#xff0c;也没有相关的SAMPLE#xff0c;于是乎#xff0c;开始投入研究。大多数scrollview的例子只有在cocos2d-x里才用到#xff0c;那么CH5里要用到滚动条怎么理呢#xff1f;有人说用tableview#…经过一段时间的学习才发现CH5里scrollview的例子很少也没有相关的SAMPLE于是乎开始投入研究。大多数scrollview的例子只有在cocos2d-x里才用到那么CH5里要用到滚动条怎么理呢有人说用tableviewOMG这个玩意不但复杂而且累赘用一个简单的功能要写一大堆代码。OK哥与scrollview卯上了最后终于完美解决。估计应该是全论坛首创因此转载要注明出处。分享研究代码主要解决俩大难题1滑动优先的问题如果在scrollview里放Menu不能滑动并且触发menu事件。2当menu滑动出ScrollView的时候还可以点击。解决方案1重写Menuvar MyScrollMenu cc.Menu.extend({ ctor : function () { this._super(); cc.associateWithNative(this, cc.Layer); if (touches in sys.capabilities || sys.platform browser) this.setTouchEnabled(true); else if (mouse in sys.capabilities) this.setMouseEnabled(true); }, registerWithTouchDispatcher : function () { Global.director.getTouchDispatcher().addTargetedDelegate(this, cc.MENU_HANDLER_PRIORITY 1000, true); }, onTouchBegan : function (touch, e) { this.touchPY1 touch.getLocation().y; if (this._state ! cc.MENU_STATE_WAITING || !this._visible || !this._enabled) { return false; } for (var c this._parent; c ! null; c c.getParent()) { if (!c.isVisible()) { return false; } } this._selectedItem this._itemForTouch(touch); if (this._selectedItem) { this._state cc.MENU_STATE_TRACKING_TOUCH; this._selectedItem.selected(); return true; } }, onTouchMoved : function (touch, e) { this.touchPY2 touch.getLocation().y; if (Math.abs(this.touchPY1 - this.touchPY2) 0 this._selectedItem) { this._selectedItem.unselected(); this._selectedItem null; } }, onTouchEnded : function (touch, e) { if (this._selectedItem) { this._selectedItem.unselected(); this._selectedItem.activate(); Global.audioEngine.playEffect(Res.Sounds.Main.click); } this._state cc.MENU_STATE_WAITING; } });MyScrollMenu.create function () { var ret new MyScrollMenu(); if (arguments.length 0) { ret.initWithItems(null, null); } else if (arguments.length 1) { if (arguments[0]instanceof Array) { ret.initWithArray(arguments[0]); return ret; } } ret.initWithItems(arguments); return ret;};2)添加点击范围判断var scrollViewTestLayer cc.Layer.extend({ ctor : function () { this._super(); cc.associateWithNative(this, cc.Layer); if (touches in sys.capabilities || sys.platform browser) this.setTouchEnabled(true); else if (mouse in sys.capabilities) this.setMouseEnabled(true); var container cc.LayerColor.create(cc.c4b(0, 0, 255, 255), 320, 360); container.addChild(new MyScrollMenu() ); var scrollView cc.ScrollView.create(cc.size(320, 300), container); scrollView.setBounceable(true); scrollView.setDirection(1); scrollView.updateInset(); scrollView.setPosition(cc.p(0, 120)); scrollView.setContentOffset(cc.p(0, 0), true); //scrollView.ignoreAnchorPointForPosition(false); scrollView.setDelegate(this); this.addChild(scrollView); }, registerWithTouchDispatcher : function () { Global.director.getTouchDispatcher().addTargetedDelegate(this, cc.MENU_HANDLER_PRIORITY - 100, true); }, onTouchBegan : function (touch, e) { //cc.log(touch.getLocation()); if (cc.rectContainsPoint(cc.rect(0, 120, 320, 300), touch.getLocation())) { //cc.log(111111); return false; } else { //cc.log(222222); return true; } }, scrollViewDidScroll : function (view) { //cc.log(scrollViewDidScroll); }, scrollViewDidZoom : function (view) { //cc.log(scrollViewDidZoom); } });这些代码是经过好几天的研究得到的请大家尊重别人的劳动成果转载标明出处谢谢。转载于:https://www.cnblogs.com/cosiray/archive/2013/05/05/3061143.html