加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2dx richText

发布时间:2020-12-14 21:05:43 所属栏目:百科 来源:网络整理
导读: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()) lo
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)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读