[Resolved] Displaying a image absolute position

Hi, I have a problem to display a image.

I would like to display a image at the same place to iphone (ipad) and android devices.
A exemple, I display a image at the bottom left of the iphone simulator, and on the android simulator, the image moves, and the image is not at the same place.

A image example :

http://image.noelshack.com/fichiers/2012/30/1343228520-sans-titre.png

The code :

Main.lua

display.setStatusBar(display.HiddenStatusBar)  
  
local height = display.contentHeight  
local width = display.contentWidth  
  
-- bg  
bg\_menu = display.newImageRect( "media/imgs/bg\_menu.png", 570, 380 )  
bg\_menu.x = width\*0.5  
bg\_menu.y = height\*0.5  
  
-- bouton  
pad\_haut = display.newImageRect( "media/ingame/pad/btn\_pad\_haut.png", 47, 47 )  
pad\_haut.x = width\*.05  
pad\_haut.y = height\*.92  

Config.lua

application =  
{  
 content =  
 {  
 width = 320,  
 height = 480,  
 scale = "letterbox",  
 fps = 30,  
  
  
 imageSuffix =  
 {  
 ["\_x2"] = 2, -- A good scale for   
 ["\_x4"] = 4, -- A good scale for   
 },  
 },  
  
}   

Please help (sorry for that english) [import]uid: 157253 topic_id: 29043 reply_id: 329043[/import]

I believe this is because of your use of letterbox scaling - have you tried other scaling methods? [import]uid: 52491 topic_id: 29043 reply_id: 116875[/import]

with

scale = "zoomStretch",  

The button image rest at the same place, but I read the better way to do a game who work and every device is “letterbox”, zoomStretch is good or not ?

EDIT :

I edit my code, always with letterbox :

display.setStatusBar(display.HiddenStatusBar)  
  
local height = display.contentHeight  
local width = display.contentWidth  
  
-- bg  
bg\_menu = display.newImageRect( "media/imgs/bg\_menu.png", 570, 380 )  
bg\_menu.x = width\*0.5  
bg\_menu.y = height\*0.5  
  
-- bouton  
pad\_haut = display.newImageRect( "media/ingame/pad/btn\_pad\_haut.png", 47, 47 )  
pad\_haut.x = width\*.05 + display.screenOriginX   
pad\_haut.y = height\*.92 + display.screenOriginY   
  
pad\_bas = display.newImageRect( "media/ingame/pad/btn\_pad\_bas.png", 47, 47 )  
pad\_bas.x = width\*.147 + display.screenOriginX   
pad\_bas.y = height\*.92 + display.screenOriginY   

So I add + display.screenOriginY and + display.screenOriginX and the image rest at the same place, but and iPad, the image is decale in Y …

Image example :
http://image.noelshack.com/fichiers/2012/30/1343238242-sans-titre.png

Help :slight_smile: [import]uid: 157253 topic_id: 29043 reply_id: 116876[/import]

@gonix, if you absolutely want the objects to appear on the lower left corner, I think you’ll have to code it in for each specific device that does not look right with your current config setting. Getting this working on iOS (between iPhone vs iPad) would be super easy, but if you want to accommodate every Android device, then… with so many different screen sizes/ratios, you may just have to figure out how to capture the the screen size/ratio of the device you’ve installed your app and then position these objects accordingly.

This code posted by @mmagrilov on code share might help:
http://developer.coronalabs.com/code/calculating-actual-boundaries-your-application-and-device-screen-size

I also remember seeing a great huge list of screen dimension/ratio for various Android devices posted on code share, but I misplaced the link somewhere. But if you look, I’m sure you’ll find it.

Naomi
[import]uid: 67217 topic_id: 29043 reply_id: 116909[/import]

I am thinking out loud so this might not work.

Stick with letterbox. However let me mention a few things I remember about OriginX/Y.

First is OriginX and OriginY only give you the difference between the left and top of your target screen size and the actual screen size. So to get the total extra width/height you need to multiply these numbers *2.

Second the numbers you get will be a negative if the screen is larger and so I assume it will give a positive number if the screen is smaller (than the target size set in config). So when you add them your actually subracting on the ipad making the width or height smaller. So your code is assuming the ipad is actually smaller than it is.

So I am thinking if you just subtract (instead of add) OriginX and Y (times 2) then it should end up where you expect it to be. [import]uid: 56820 topic_id: 29043 reply_id: 116913[/import]

@Naomi : Thank you very much

@anderoth : Thank you, it’s work fine even if I did not understand all what I have done ^^’, but it’s work fine. [import]uid: 157253 topic_id: 29043 reply_id: 116926[/import]