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

4 replies to this topic
placing objects
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/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

  • 26,331 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: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,331 posts
  • Enterprise

Hi @wvtxman.

 

Please re-read my post above. The code you posted isn't formatted. Use the blue <> button in the row with Bold and Italic and paste your code in the popup window. But your config.lua has a big impact on how things work. This is why I asked you to provide a full sample project in a .zip file.

 

Please read the post I referred to here: https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/

 

Asking better questions translates to better, more helpful answers. It's our long standing mantra: Help us Help you!

 

Rob



[TOPIC: post.html]
#5

yosu

[GLOBAL: userInfoPane.html]
yosu
  • Contributor

  • 525 posts
  • Corona SDK

For me, i would put the graphics that will appear on top of all pages in 'main.lua'

 

Try putting 'allSquareGroup = display.newGroup()' in 'main.lua'. Then it should be on top of all other pages.




[topic_controls]
[/topic_controls]