Alignment Question for texture bigger than the phone area

Hello,

I’ve just start playing around with Corona and I made a default project. The config.lua file says the height of the display is 480.

I have a jpg that’s a height of 1138.
[lua]background = display.newImage( “background.jpg” )[/lua]

From what I’ve read I would expect that to display the image centered. The center of the phone display would align with the center of the image. But this isn’t the case. (The image is higher up than would be expected but it’s hard to tell how far out it is)

Is there something obvious I’ve missed?

(I tried using the world.jpg from one of the example programs and that worked fine and as I’d expect)

Thanks for any help!
-Dan [import]uid: 133358 topic_id: 23062 reply_id: 323062[/import]

Wait I bet it’s because it’s not a power of 2!
Edit: I’ve edit it to 512x1024 and it’s still not centered aligned so I must be missing something. [import]uid: 133358 topic_id: 23062 reply_id: 92229[/import]

It would actually be at 0,0 with a top right reference point in that scenario. (It normally appears centered as the background image is typically the same size as the screen.)

Add;

[lua]background.x, background.y = 160, 240[/lua]

That should do it :slight_smile: [import]uid: 52491 topic_id: 23062 reply_id: 92354[/import]

Thanks!

To me in the docs it seems to suggest an origin at the centre of the image.


You can optionally specify that the image’s top-left corner be located at the coordinate (left, top); if you don’t supply both coordinates, the image will be centered about its local origin.

The local origin is at the center of the image; the reference point is initialized to this point. This means that once the image is onscreen, any further access to x or y will refer to the center of the image, not to the top/left values optionally specified in display.newImage().

http://developer.anscamobile.com/content/display-objects

Are the docs out of date or am I misinterpreting them?
[import]uid: 133358 topic_id: 23062 reply_id: 92377[/import]

Some visuals, like text, automatically have a top left reference point.

With the background in your case it’s just the size - it’s too big for the screen and doesn’t line up - but if you specify coords as I showed above you will see it is using a center reference point once it is loaded :slight_smile: [import]uid: 52491 topic_id: 23062 reply_id: 92512[/import]