如何将圆的边缘对齐在一起?

时间:2016-11-11 10:42:10

标签: for-loop lua position corona shape

如何将圆的边缘对齐在一起?盒子的边缘是对齐的,但是我的圆圈/边缘没有对齐,而是相互占据了空间......

    local areaPadding = 5
    local topPadding = 160
    local answerOffset = 6
    local area = answer_rect.width - (areaPadding*-5)
    local answerHeight = (area-topPadding-(answerOffset*#q.answers))/#q.answers
    local textX = numberX + 20
    local textW = _W - textX - 24

    local y = answer_rect.x + areaPadding + topPadding
    local howManyAnswers = #q.answers

- 如果必要减少answerHeight,请确保答案适合屏幕大小         local offset =(_W - (howManyAnswers *(answerHeight + answerOffset) - answerOffset))* 0.5

    for i=1, howManyAnswers do
        local rect = display.newCircle(quizGroup, offset + (answerHeight+answerOffset)*(i-1), y, answerHeight, answerHeight )
        rect.anchorX, rect.anchorY = 0, 0
        rect.id = "answer"
        rect.index = i
        rect:setFillColor(0.1)
        rect:addEventListener("touch", buttonTouched)

        local answer = display.newText({parent=quizGroup, text=q.answers[i], width=textW, height=0, font=native.systemFont, fontSize=150})
        answer.x = rect.x + rect.width * 0.3
        answer.y = rect.y + rect.height * 0.5
        answer.anchorX = 0
        answer:setFillColor(1)
    end
end

enter image description here enter image description here

1 个答案:

答案 0 :(得分:1)

尝试

O(g(n)) = O(n^2)