FullScreen Problem

Hi all,

I use https://coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/ for create fullscreen app and i use this codes for fullscreen background image.

 background\_Obj = display.newImageRect("Pictures/background.jpg", display.actualContentWidth, display.actualContentHeight) background\_Obj.x,background\_Obj.y = display.contentCenterX,display.contentCenterY

But my problem is that I want to keep an object on a certain point of the background.

When I use the  [View -> View As -> one of the devices] Object distance is the point of the background.

How can on any device, keep positioning an object on a particular point of my background ?

Depending on your background image, the way you’re sizing it could end up distorting the image.  You should load the background at a fixed size (the size of your @1x image).

But to answer your question, your background is centered.  Therefore anything you position relative to the center, will be in the positions you expect them to be.  display.contentCenterX + 100 for instance.

Rob

how can me load the image with fixed size and fullscreen ?

how can me understand how much distorted image?

I use the same method ( display.contentCenterX + n ), but still gets distort.

Assuming a landscape app, designed to work from iPads to 16:9 wide screens, you would have your background be the following sizes:

570x360    background.jpg (or .png whatever you’re using)

1140x720  background@2x.jpg

2280x1440 background@4x.jpg

Your config.lua is set for a 320x480 base screen.

Then your code would be:

local background = display.newImageRect(“background.jpg”, 570, 360)

background.x = display.contentCenterX

background.y = display.contentCenterY

Now on a wide screen 16:9 type screen, the top and bottom of the background will be cut off.  On an iPad your left and right sides will be cut off.  Don’t put anything in the background in these areas that you cannot afford to have off screen.  You have to plan for that.  Then if you have objects that you might have put in your background that need to fit around edges, they will need to be loaded as their own graphics and positioned near the edges as you like.

Rob

Depending on your background image, the way you’re sizing it could end up distorting the image.  You should load the background at a fixed size (the size of your @1x image).

But to answer your question, your background is centered.  Therefore anything you position relative to the center, will be in the positions you expect them to be.  display.contentCenterX + 100 for instance.

Rob

how can me load the image with fixed size and fullscreen ?

how can me understand how much distorted image?

I use the same method ( display.contentCenterX + n ), but still gets distort.

Assuming a landscape app, designed to work from iPads to 16:9 wide screens, you would have your background be the following sizes:

570x360    background.jpg (or .png whatever you’re using)

1140x720  background@2x.jpg

2280x1440 background@4x.jpg

Your config.lua is set for a 320x480 base screen.

Then your code would be:

local background = display.newImageRect(“background.jpg”, 570, 360)

background.x = display.contentCenterX

background.y = display.contentCenterY

Now on a wide screen 16:9 type screen, the top and bottom of the background will be cut off.  On an iPad your left and right sides will be cut off.  Don’t put anything in the background in these areas that you cannot afford to have off screen.  You have to plan for that.  Then if you have objects that you might have put in your background that need to fit around edges, they will need to be loaded as their own graphics and positioned near the edges as you like.

Rob