Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Making objects look the same on all screens.
Started by wvtxman Apr 10 2019 11:42 AM

2 replies to this topic
placing objects
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

wvtxman

[GLOBAL: userInfoPane.html]
wvtxman
  • Observer

  • 3 posts
  • Corona SDK

Need help placing objects on screen to stay in same position on all screens.  I've looked and searched for weeks and can not figure it out.  I've attached a small program.



[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,467 posts
  • Enterprise

Hi @wvtxman and welcome to the Corona community forums. Your sample program did not attach. It's best to upload it to DropBox, Google Drive or similar and provide a URL for people to download it, or post the project to a service like GitHub.

 

It would be really helpful if you provided more information. There really isn't much here for us to go on. If you provided screenshots of how its behaving on different screens that would be quite helpful too.

 

With the lack of information you've provided, I can just suggest that you read this post and see if it helps you: https://coronalabs.com/blog/2018/08/08/understanding-content-scaling-in-corona/

 

You should also go to the Newbie forum and read the "Ask a better question, get a better answer" post.

 

Rob



[TOPIC: post.html]
#3

wvtxman

[GLOBAL: userInfoPane.html]
wvtxman
  • Observer

  • 3 posts
  • Corona SDK

this is the code I was trying to make the rectangles be in the same location on all screens including iPads.

 

 

 local numberOfSquares = 9
    local sizeOfSquares = 20
 
    local paint = {
        type = "gradient",
        color1 = { .239, .217,.32},
        color2 = { .128, .57, .68, 0.2 },
        direction = "middle"
    }
 
 
for f=1, numberOfSquares  do
    rect[f] = {}
    for g=1, numberOfSquares -2 do
        rect[f][g] = 0
    end
end
    
    spaceX = 60 + display.safeScreenOriginX
    spaceY = 30 + display.safeScreenOriginY
    myY = spaceY 
   
    local squareNumber = 0
 
    for j=1,numberOfSquares do
        
          allSquareGroup = display.newGroup() 
       
        for i=1,numberOfSquares do
         
            squareNumber = squareNumber + 1
            squareGroup = display.newGroup()  
            rect[j][i] = display.newRect( sizeOfSquares, sizeOfSquares, sizeOfSquares, 30 )
            --rect[j][i]:setFillColor( 100, 100, 200 )
            rect[j][i].fill = paint
            rect[j][i]:setStrokeColor( 225,236,41)
            rect[j][i].strokeWidth = 1
            rect[j][i].num = ("" ..tostring(j)  ..tostring(i))
            rect[j][i].number = squareNumber
            rect[j][i].x = spaceX
            rect[j][i].y = spaceY
            rect[j][i].isVisible = true
            local text = display.newText("" .. tostring(j) .. tostring(i) ,rect[j][i].x, rect[j][i].y, native.systemFontBold, 12  )
            text:setTextColor(0, 0,0,1)
            local sx = rect[j][i].contentWidth/text.contentWidth
            local sy = rect[j][i].contentHeight/text.contentHeight
            local scale = (sx < sy ) and sx or sy
 
            text:scale( scale, scale )
          
            squareGroup.num = squareNumber
            squareGroup:insert(rect[j][i])
            --squareGroup:addEventListener("touch", squareTouched)
            table.insert( allSquareGroup ,squareGroup)
            allSquareGroup:insert(squareGroup)
            
            spaceY = rect[j][i].y  + 33
            
             if i == numberOfSquares  then
               spaceY =  myY
                         end
    end -- for i
               
      spaceX =  spaceX + 25
    end --for j



[topic_controls]
[/topic_controls]