for loop - How to align the edge of the circle together? -


how align edge of circle together? edge of boxes align circles circumference/edge not align instead occupying each other spaces..

    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 

-- make sure answers fit screen size if neccessary decrease answerheight local offset = (_w - (howmanyanswers * (answerheight+answeroffset) - answeroffset)) * 0.5

    i=1, howmanyanswers         local rect = display.newcircle(quizgroup, offset + (answerheight+answeroffset)*(i-1), y, answerheight, answerheight )         rect.anchorx, rect.anchory = 0, 0         rect.id = "answer"         rect.index =         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 

end

enter image description here enter image description here

try

local _w = display.contentwidth local _h = display.contentheight  local areapadding = 12 local toppadding = 16 local answeroffset = 30 -- put in space labels local area = answer_rect.height - (areapadding*2.5) local howmanyanswers = #q.answers local textx = numberx + 20 local textw = _w - textx - 24 local answerheight = (area-toppadding-(answeroffset*#q.answers))/howmanyanswers  local y = answer_rect.x + areapadding + toppadding  -- make sure answers fit screen size if neccessary decrease answerheight local offset = (_w - (howmanyanswers * (answerheight+answeroffset))) * 0.5  i=1, howmanyanswers   local rect = display.newrect(quizgroup, offset + answeroffset +(answerheight+answeroffset)*(i-1), y, answerheight, answerheight)   rect.anchorx, rect.anchory = 0, 0   rect.id = "answer"   rect.index =   rect:setfillcolor(0.1)   rect:addeventlistener("touch", buttontouched)    local label = display.newtext({parent=quizgroup, text=i..".", font=native.systemfont, fontsize=20})   label.x = rect.x - answeroffset * 0.5   label.y = rect.y + 0.5 * rect.height    label:setfillcolor(0.4)    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.5   answer.y = rect.y + rect.height * 0.5   answer:setfillcolor(1) end 

Comments

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -