cocos2d_x+lua【4.2】 ------ScollView的使用
oDustGgg个人原创、欢迎转载、转载请注明出处、http://blog.csdn.net/odustggg/article/details/8179712
一、创建滚动层function create_Scrollview()--infolayer为整个滚动层 有什么元素都加到上面去local infoRect = CCRectMake(45, 105, 260, 370)infolayer = CCLayerColor:layerWithColorWidthHeight(ccc4(0, 128, 128, CORLORLAYERENABLE), infoRect.size.width, infoRect.size.height)infolayer:setAnchorPoint(CCPointMake(0.5, 1.0))--anchorPoint这个属性虽然是属于CCNode的、但CCLayer设置anchorPoint没有效果、--CCLayer的anchorPoint被默认设定在(0, 0)、在setAnchorPoint之前要先设置setIsRelativeAnchorPoint = true infolayer:setIsRelativeAnchorPoint(true)infolayer:setPosition(PT(130, 370))--ScrollLayerExtLayer为当前显示的层ScrollLayerExtLayer = CCScrollLayerExt:CreateScrollLayerExt(infolayer, infoRect)-- 两种排列 SCROLLLAYERSTYLE_HORIZONTAL 水平 SCROLLLAYERSTYLE_VERTICAL 竖直 ScrollLayerExtLayer:SetListViewCustormer(SCROLLLAYERSTYLE_VERTICAL)--拖动时候的滚动效果ScrollLayerExtLayer:SetScrollBackFlg(true)--显示要不要显示滚动条,第一个是水平 第二个参数垂直 ScrollLayerExtLayer:SetScrollerShowFlg(false, false)layerBG:addChild(ScrollLayerExtLayer)