https://img-blog.csdnimg.cn/32db9ce43ef64316a2e37a31f4cee033.gif
编程小鱼酱yu612.com,点击前往

cocos2d-lua3.7控件篇(五)-PageView demo

PageVIew实现翻页的效果

这里写图片描述

使用cocos2d-lua社区版

local MainScene = class("MainScene", function()
    return display.newScene("MainScene")
end)

function MainScene:ctor()
    local layer = cc.LayerColor:create(cc.c4b(155, 155, 155, 255))
    layer:addTo(self)

    self:createUIPageView()
end

function MainScene:createUIPageView()

    local page = ccui.PageView:create()
    page:setContentSize(800,400)

     for i = 1 , 18 do
        local layout=ccui.Layout:create()
        layout:setPosition(10,30*i)
        print("test")
        layout:setContentSize(cc.size(100,100))
        local lbl3 = cc.Label:create()
        lbl3:setString("-----------"..i)
        lbl3:setContentSize(cc.size(100,100))
        lbl3:setPosition(10,200)
        layout:addChild(lbl3)
           local lbl4 = cc.Label:create()
        lbl4:setString("aaaaaaaaaaaa"..i)
        lbl4:setContentSize(cc.size(100,100))
        lbl4:setPosition(10,230)
        layout:addChild(lbl4)


        page:addPage(layout)---一个layout 为一个 page内容

    end

    page:addTo(self)
end

function MainScene:onEnter()
end

function MainScene:onExit()
end

return MainScene
posted @ 2018-01-12 11:57  鱼酱  阅读(375)  评论(0编辑  收藏  举报

https://img-blog.csdnimg.cn/32db9ce43ef64316a2e37a31f4cee033.gif
编程小鱼酱yu612.com,点击前往