【发布时间】:2020-10-24 10:19:46
【问题描述】:
所以我一直在 Corona 开发一个跳棋游戏,并且一直在 Lua 中工作只是为了掌握它,在制作我的跳棋棋盘时,我有一面我无法绘制的隐形墙。就像我正在使用一个用来画圆的函数一样,它可以在除屏幕右侧之外的任何其他地方工作。我不知道错误来自哪里,只是想知道你们是否可以帮助我?如果我的代码很乱,我也很抱歉,我仍在学习制作整个程序的技巧。提前致谢。 :)
代码在下面-
--All the essential values
local widget = require ("widget")
local redCount = 12
local blackCount = 12
local length = 40.05
local x = length / 2
local y = 80
local startX = x
local startY = y
local allowMoves = true
local black = {0, 0, 0}
local red = {1, 0, 0}
--Title Display
local title = display.newText("Checkers", display.contentCenterX, 10, native.systemFontBold, 40)
--Functions
local function checkWinner()
if (redCount == 0) then
display.newText("Black Team Wins!!!", display.contentCenterX, display.contentHeight - 60, nativeSystemFontBold, 37)
elseif (blackCount == 0) then
display.newText("Red Team Wins!!!", display.contentCenterX, display.contentHeight - 60, nativeSystemFontBold, 40)
end
end
local function drawPoint(x, y, color)
local pixel = display.newRect(x, y, 2.5, 2.5)
pixel.fill = color
end
local function makeCircle(h, k, radius, color)
for i = 1, 180, 1 do
local b = math.sqrt((radius * radius) - ((i - h) * (i - h))) + k
drawPoint(i, b, color)
drawPoint(i, (b * -1) + k * 2, color)
end
end
--Making the board
for i = 1, 8, 1
do
for k = 1, 4, 1
do
if i % 2 == 1 then
display.newRect( x, y, length, length, 30)
else
display.newRect( x + length, y, length, length, 30)
end
x = x + (startX * 4)
end
y = y + length
x = startX
end
--Making the outline
display.newRect(startX, startY - (length / 2), length * 15, 3, 30)
display.newRect(startX, y - (length / 2), length * 15, 3, 30)
display.newRect(startX - (length / 2), startY, 3, length * 15, 30)
display.newRect(320.4, startY, 3, length * 15, 30)
--Making red peices
x = length / 2
y = 80
for i = 1, 3, 1
do
for k = 1, 4, 1
do
if i % 2 == 1 then
makeCircle( x, y, 17, red)
else
makeCircle( x + length, y, 17, red)
end
x = x + (startX * 4)
end
y = y + length
x = startX
end
【问题讨论】:
-
另外,我刚刚了解到我可以使用 newCircle() 函数,我觉得自己像个白痴,让我快速重新制作它。