【发布时间】:2014-01-15 03:07:53
【问题描述】:
我正在尝试制作一款类似于著名的 Dots 的游戏:一款关于连接的游戏,您必须在其中连接相同颜色的点。我遇到的问题是画线。它必须是直的并且从一个点(物理对象)开始并捕捉到另一个相同颜色的点。如果您能帮助我了解如何绘制一条与另一个对象对齐的直线,我们将不胜感激。
【问题讨论】:
标签: sdk line coronasdk draw physics
我正在尝试制作一款类似于著名的 Dots 的游戏:一款关于连接的游戏,您必须在其中连接相同颜色的点。我遇到的问题是画线。它必须是直的并且从一个点(物理对象)开始并捕捉到另一个相同颜色的点。如果您能帮助我了解如何绘制一条与另一个对象对齐的直线,我们将不胜感激。
【问题讨论】:
标签: sdk line coronasdk draw physics
您不需要折断线,您只需要让它看起来像是在折断。
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
【讨论】: