Objects sizes on Simulator/Android

Hi All,

I have a concerns about setting objects sizes and coordinates. As far as I understand from documentation, content size is not actual pixel resolution, but only proportions for displaying a content. I have it default:

application =

{

    content =

    {

        width = 320,

        height = 480, 

        scale = “letterbox”,

        fps = 60,

    },

}

I understand that if I place an image with this code, it should be displayed more or less in the same place, regardless of phone display resolution?

restartButton = display.newImageRect(“assets/reset.png”, 20, 20)

    restartButton.x = display.contentCenterX

    restartButton.y = 500

So my problem I don’t understand is, why on simulator everything looks as intended, but when deployed to the phone, all objects are placed differently, and are much smaller (depending on device display resolution). How to solve it? Should I check a device resolution and place objects basing on that, or is there any other way? Any settings which I forgot?

Screenshots attached to show you differences between Simulator and Android.

thanks for help

Those are two entirely different pictures. Also that cant be the code you create them with.

Yes, that was a bad example, here better. Code:
 

title = display.newText( “That’s Life”, display.contentCenterX, 50, “FePIrm27C.otf”, 40 )

title:setFillColor( 1, 1, 1 )

newGameText = display.newText( stringDictionary[“PARAM_NEW_GAME”], display.contentCenterX, 160, “FePIrm27C.otf”, 16 )

newGameText:setFillColor( 1, 1, 1 )

newGameFeelGoodButton = display.newImageRect(“assets/white-paint-brush-stroke-3.png”, 200, 50)

newGameFeelGoodButton.x = display.contentCenterX

newGameFeelGoodButton.y = 220

helpButton1 = display.newImageRect(“assets/help.png”, 25, 25)

helpButton1.x = display.contentCenterX + 115

helpButton1.y = 220

helpButton1.alpha = 0.35

newGameFeelGood = display.newText( stringDictionary[“PARAM_NEW_GAME_FG”], display.contentCenterX, 220, “FePIrm27C.otf”, 16 )

newGameFeelGood:setFillColor( 0, 0, 0 )

newGameHardButton = display.newImageRect(“assets/white-paint-brush-stroke-5.png”, 200, 50)

newGameHardButton.x = display.contentCenterX

newGameHardButton.y = 320

helpButton2 = display.newImageRect(“assets/help.png”, 25, 25)

helpButton2.x = display.contentCenterX + 115

helpButton2.y = 320

helpButton2.alpha = 0.35

newGameHard = display.newText( stringDictionary[“PARAM_NEW_GAME_RL”], display.contentCenterX, 320, “FePIrm27C.otf”, 16 )

newGameHard:setFillColor( 0, 0, 0 )

optionsIcon = display.newImageRect( “assets/options.png”, 40, 40)

optionsIcon.x = display.contentCenterX

optionsIcon.y = 450

And this is how it looks on the phone / simulator:

You should create a sample project and upload it here. That code wont cause that without some weird config or other stuff

Thanks pixec,

Finally after more than a week I found the reason, but it was definitely what I was expecting…

In project folder I had two files:

“summary.lua” (used in game)

“summary — old.lua” (only a backup file, not loaded in game)

Result was broken graphic displaying in all scenes and runtime error while loading “summary.lua” in game - all of that only on Android devices.

Removing unused file “summary — old.lua” from the project folder fixed everything. Graphic is now as intended, no errors while loading “summary.lua”.

Those are two entirely different pictures. Also that cant be the code you create them with.

Yes, that was a bad example, here better. Code:
 

title = display.newText( “That’s Life”, display.contentCenterX, 50, “FePIrm27C.otf”, 40 )

title:setFillColor( 1, 1, 1 )

newGameText = display.newText( stringDictionary[“PARAM_NEW_GAME”], display.contentCenterX, 160, “FePIrm27C.otf”, 16 )

newGameText:setFillColor( 1, 1, 1 )

newGameFeelGoodButton = display.newImageRect(“assets/white-paint-brush-stroke-3.png”, 200, 50)

newGameFeelGoodButton.x = display.contentCenterX

newGameFeelGoodButton.y = 220

helpButton1 = display.newImageRect(“assets/help.png”, 25, 25)

helpButton1.x = display.contentCenterX + 115

helpButton1.y = 220

helpButton1.alpha = 0.35

newGameFeelGood = display.newText( stringDictionary[“PARAM_NEW_GAME_FG”], display.contentCenterX, 220, “FePIrm27C.otf”, 16 )

newGameFeelGood:setFillColor( 0, 0, 0 )

newGameHardButton = display.newImageRect(“assets/white-paint-brush-stroke-5.png”, 200, 50)

newGameHardButton.x = display.contentCenterX

newGameHardButton.y = 320

helpButton2 = display.newImageRect(“assets/help.png”, 25, 25)

helpButton2.x = display.contentCenterX + 115

helpButton2.y = 320

helpButton2.alpha = 0.35

newGameHard = display.newText( stringDictionary[“PARAM_NEW_GAME_RL”], display.contentCenterX, 320, “FePIrm27C.otf”, 16 )

newGameHard:setFillColor( 0, 0, 0 )

optionsIcon = display.newImageRect( “assets/options.png”, 40, 40)

optionsIcon.x = display.contentCenterX

optionsIcon.y = 450

And this is how it looks on the phone / simulator:

You should create a sample project and upload it here. That code wont cause that without some weird config or other stuff

Thanks pixec,

Finally after more than a week I found the reason, but it was definitely what I was expecting…

In project folder I had two files:

“summary.lua” (used in game)

“summary — old.lua” (only a backup file, not loaded in game)

Result was broken graphic displaying in all scenes and runtime error while loading “summary.lua” in game - all of that only on Android devices.

Removing unused file “summary — old.lua” from the project folder fixed everything. Graphic is now as intended, no errors while loading “summary.lua”.