cocos2dx richText

local function createMyRichText(fieldSize,spTb)
    local rc=ccui.RichText:create()
--    node:addChild(rc)
    rc:ignoreContentAdaptWithSize(false)
    rc:setContentSize(fieldSize)
    for key,var in pairs(spTb) do
        var:setContentSize(var:getBoundingBox())
        local rcItem=ccui.RichElementCustomNode:create(key,cc.c3b(255,0),255,var)
        rc:pushBackElement(rcItem)
    end
    return rc
end
    local spTb={}
    local sp1=cc.Sprite:create("dog.png")
    sp1:setColor(cc.c3b(0,255))
    sp1:setScale(0.5)
    
    local text1=cc.Label:createWithSystemFont("你好啊,","黑体",30)
    text1:setColor(cc.c3b(255,0))
    local text2=cc.Label:createWithSystemFont("我擦,","Arial",90)
    text2:setScale(0.4)
    text2:setColor(cc.c3b(0,225,0))
    local text3=cc.Label:createWithSystemFont("孙子啊,","楷体",30)
    text3:setColor(cc.c3b(0,255))
    local text4=cc.Label:createWithSystemFont("苹果笔记本,","宋体",30)
    text4:setColor(cc.c3b(0,255))
    local text5=cc.Label:createWithSystemFont("华为,",30)
    text5:setColor(cc.c3b(255,0))
    local text6=cc.Label:createWithSystemFont("宏碁啊,",30)
    text6:setColor(cc.c3b(127,127))
    table.insert(spTb,text1)
    table.insert(spTb,text2)
    table.insert(spTb,text3)
    table.insert(spTb,text4)
    table.insert(spTb,text5)
    table.insert(spTb,text6)
    table.insert(spTb,sp1)
        
    local richText=createMyRichText(cc.size(400,400),spTb)
    richText:setPosition(cc.p(480,320))
    
    ly:addChild(richText)

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...