(adsbygoogle = window.adsbygoogle || []).push({});
给文字添加下划线,其实也就是画一条直线,只是直线放在了文字下方而已
代码语言:javascript复制-- 创建并返回一个 DrawNode (线性)对象。
-- @function [parent=#display] newLine
-- @param table point table
-- @param table params 有参数,边线色 borderColor 及边线宽度 borderWidth
-- @return DrawNode#DrawNode ret (return value: cc.DrawNode)
-- @see ShapeNode
--[[--
创建并返回一个 DrawNode (线性)对象。
格式:
shape = display.newLine(point表, [参数])
-- 创建一个线宽为2,颜色为红色,从(10,10)到(100,100)的线段
local shape3 = display.newLine({{10, 10}, {100,100}},
{borderColor = cc.c4f(1.0, 0.0, 0.0, 1.0),
borderWidth = 1})
]]
function display.newLine(points, params)
local radius
local borderColor
local scale
if not params then
borderColor = cc.c4f(0,0,0,1)
radius = 0.5
scale = 1.0
else
borderColor = params.borderColor or cc.c4f(0,0,0,1)
radius = (params.borderWidth and params.borderWidth/2) or 0.5
scale = checknumber(params.scale or 1.0)
end
for i, p in ipairs(points) do
p = cc.p(p[1] * scale, p[2] * scale)
points[i] = p
end
local drawNode = cc.DrawNode:create()
drawNode:drawSegment(points[1], points[2], radius, borderColor)
return drawNode
end