简体   繁体   中英

Invisible wall in Corona SDK?

So I have been working on a checkers game in Corona and have been working in Lua just to get a hang of it and while making the pieces of my checkers board I have this invisible wall that I am not able to draw over. Like I am using a function I use to draw a circle and it works anywhere else but in the right side of my screen. I have no leads on where the error is coming from just wondering if you guys could help me out? Also I am sorry if my code is messy I am still learning the ropes to making whole programs. Thanks in advance. :)

Code is here below-

--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

Display thats shown on the phone

You should use physics.newBody to make the line into a ("rigid") body. Then make its colour transapent using the alpha carathestic of the colours.

For further reference I highly reccomend you to look at the documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM