Can someone correct where I’m going wrong here (my head is starting to hurt). How should I scale this groupObject & set config.lua such that I achieve this goal?
Goal: For each device type that:
(a) Vertical Content Area takes up full vertical size of the device and
(b) Desired vertical content to display on screen (VERT_PIXCEL_HEIGHT_TO_DISPLAY) is scaled to the Vertical Content Area
Therefore the test is to run through permutations of (a) VERT_PIXCEL_HEIGHT_TO_DISPLAY and (b) device type on the simulator
Question: How to setup (a) config.lua and (b) scaling of “contentGroup” below to achieve this?
main.lua
-- Setup display.setStatusBar( display.HiddenStatusBar ) -- Input Parameter to Manipulate local VERT\_PIXCEL\_HEIGHT\_TO\_DISPLAY = 300 -- Could be say 300, 400 or 500 -- Grid Pattern local contentGroup = display.newGroup() for x=1,10 do for y=1,5 do local myRectangle = display.newRect(contentGroup, 0, 0, 100,100) myRectangle.strokeWidth = 2 myRectangle:setFillColor(140, 140, 140, 50) myRectangle:setStrokeColor(180, 180, 180) myRectangle:setReferencePoint(display.TopLeftReferencePoint) myRectangle.x, myRectangle.y = (x-1)\*100, (y-1)\*100 local myText = display.newText(contentGroup, x .. ',' ..y , 0, 0, native.systemFont, 16) myText:setTextColor(255, 255, 255) myText:setReferencePoint(display.TopLeftReferencePoint) myText.x, myText.y = (x-1)\*100, (y-1)\*100 end end -- Attempt to scale local vertScaleFactor = display.contentHeight / VERT\_PIXCEL\_HEIGHT\_TO\_DISPLAY contentGroup:scale(vertScaleFactor, vertScaleFactor) print("vertScaleFactor", vertScaleFactor) -- ISSUES WITH THE ABOVE: -- iPhone: Good -- iPhone4: Good -- iPhone5: Bad, a black margin on the left appears -- iPad: Bad, part of row 4 appears at the bottom -- iPad Retina: Bad, part of row 4 appears at the bottom -- Droid: Bad, a black margin on the left appears -- Content Area - Red Rectangle (just for info) local myRectangle = display.newRect(0, 0, display.contentWidth, display.contentHeight) myRectangle.strokeWidth = 2 myRectangle:setFillColor(0, 0, 140,0) myRectangle:setStrokeColor(200, 0, 0)
build.settings
-- Supported values for orientation: -- portrait, portraitUpsideDown, landscapeLeft, landscapeRight settings = { orientation = { default = "landscape", supported = { "landscape" }, }, }
config.lua
application = { content = { width = 320, height = 480, -- scale = "zoomEven", scale = "letterbox", xAlign = "left", yAligh = "center", -- imageSuffix = -- { -- ["\_2"] = 1.5, -- ["\_3"] = 3.0, -- }, }, }