您的位置:首页 > 编程语言 > Lua

lua 创建scrollview

2014-02-21 17:03 429 查看


一、创建滚动层

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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: