[Resolved] Problem with display image x, y coordinates

Hi
I have an back ground image size 960*480 which i need to move across the screen
so i add and subtract the image.x coordinates which gives the impression that the background is moving.

but even though i initialized the image as
local image=display.newImage(“image.png”,0,0)
i noticed that the image.x value is actually 480 which is half of the width
and also image.y is 240 half of height

normally it wouldn’t be a problem but I need to stop the background when the image ends and the difference in value is causing problem .since it starts from 0 and ends at 960 i check the end condition according to that but now i have to correct it accordingly.

My question is it normal for image.x and y values to show this property or is it a glitch , is there a way around it. I don’t want to do need less calculation
[import]uid: 115284 topic_id: 25296 reply_id: 325296[/import]

Hey there,

Not a glitch, I expect you have simply forgotten to set the reference point after creation and it’s using the default (center).

After you add the image, do;

[lua]image:setReferencePoint(display.TopLeftReferencePoint)[/lua]

Then print x and y, it will return 0,0.

Peach :slight_smile: [import]uid: 52491 topic_id: 25296 reply_id: 102223[/import]

Well what do you know that was it. Thanks for the quick reply.
[import]uid: 115284 topic_id: 25296 reply_id: 102231[/import]

Not a problem - good luck with your project.

Peach :slight_smile: [import]uid: 52491 topic_id: 25296 reply_id: 102252[/import]