cocos2d JS 创建实现换行功能的聊天文本 testLable

时间:2023-03-08 20:21:39
cocos2d JS 创建实现换行功能的聊天文本 testLable

-- 创建实现换行功能的文本

function LoadLabelHeroIntroduce(objLabelContent)  //传入文本

---------------------------------

local tLabel = LG.Label:create()

--  实现换行功能      tLabel:ignoreContentAdaptWithSize(false)

tLabel:setText(objLabelContent)    // 文本赋值

local tSize = tLabel:getContentSize()    // 获取 size

local tmp_width = tSize.width

local end_height = (tmp_width / 180 +1)* (tSize.height)   // 计算高度

tLabel:setSize(Global_CCSize(180,end_height))     // 设置side

return tLabel

---------------------------------  end