display.newLine()

类型 函数
display.*
返回值 LineObject
修订 版本 2024.3703
关键字 线条、向量
另请参见 object:setStrokeColor()
object.strokeWidth
object:append()

概述

从一个点绘制一条线到另一点。另外,您还可以将点附加到线的末尾以创建轮廓形状或路径。

问题

目前,display.newLine() 对象不支持 触摸/轻触 事件。

语法

display.newLine( [parent,] x1, y1, x2, y2 [, x3, y3, ... ] )
parent (可选)

GroupObject. 用于插入线的可选显示组。

x1 / y1 (必需)

数字. 线起点坐标。

x2 / y2 (必需)

数字. 线终点坐标。

x3, y3, … (可选)

数字. 其他坐标。

示例

local star = display.newLine( 200, 90, 227, 165 )
star:append( 305,165, 243,216, 265,290, 200,245, 135,290, 157,215, 95,165, 173,165, 200,90 )
star:setStrokeColor( 1, 0, 0, 1 )
star.strokeWidth = 8