科罗纳SDK。通过画一条直线连接两个物理体

科罗纳SDK。通过画一条直线连接两个物理体,sdk,line,coronasdk,draw,physics,Sdk,Line,Coronasdk,Draw,Physics,我正在尝试制作一个像著名的圆点一样的游戏:一个关于连接的游戏,你必须连接相同颜色的圆点。我的问题是划清界限。它必须笔直,从一个点(物理对象)开始,然后捕捉到另一个相同颜色的点。如果您能帮助我理解如何绘制一条捕捉到另一个对象的直线,我将不胜感激。您不需要捕捉直线,只需要让它看起来像是在捕捉 CoronaSDK有一种方法可以画一条线,另一种方法可以画一个矩形 display.newLine( [parentGroup,], x1, y1, x2, y2 ) display.newRect( left

我正在尝试制作一个像著名的圆点一样的游戏:一个关于连接的游戏,你必须连接相同颜色的圆点。我的问题是划清界限。它必须笔直,从一个点(物理对象)开始,然后捕捉到另一个相同颜色的点。如果您能帮助我理解如何绘制一条捕捉到另一个对象的直线,我将不胜感激。

您不需要捕捉直线,只需要让它看起来像是在捕捉

CoronaSDK有一种方法可以画一条线,另一种方法可以画一个矩形

display.newLine( [parentGroup,], x1, y1, x2, y2 )
display.newRect( left, top, width, height )
你可以用你最喜欢的

local originX     -- the X coordinate where the line starts
local originY     -- the Y coordinate where the line starts
local finalX      -- the X coordinate where the line ends
local finalY      -- the Y coordinate where the line ends
local parentGroup -- the line's parent group
local rectWidth   -- the rect's width (this is the distance between originX and finalX)
local rectHeight  -- the rect's height

--with newLine
local line = display.newLine(parentGroup, originX, originY , finalX, finalY )

--with newRect
local line = display.newRect(parentGroup, originX, originY , rectWidth, rectHeight )
line:setReferencePoint( display.CenterLeftReferencePoint ) -- draws the line from the left