Background Image

Dear All,

I am new to corona and learning myself from various samples and books. I am having trouble with

  1. How are graphic displayed in the corona

for example 

local sky=  display.newImage (“sky.png”, 100, 200)

Does the above codes put the middle of the image sky.png in the the screen at x=100 and y=200. OR does it put the left edge of the image at x=100 and y=200.

That code would put the center of your image at 100 and 200. Each object has an “anchor” or “reference point”, and by default this is in the center of every object (I believe). This reference point is what corona uses to position and rotate the object.  

You can change these anchors if you need to by setting the objects anchorX and anchorY properties:

local sky = display.newImage ("sky.png", 100, 200) sky.anchorX = 0 sky.anchorY = 0

The anchor values go from 0 to 1.  

For anchorX: 0 is the left edge, 1 is the right edge and therefore 0.5 is the middle (and is the default value).

For anchorY: 0 is the top edge, 1 is the bottom and again 0.5 is the middle.

That code would put the center of your image at 100 and 200. Each object has an “anchor” or “reference point”, and by default this is in the center of every object (I believe). This reference point is what corona uses to position and rotate the object.  

You can change these anchors if you need to by setting the objects anchorX and anchorY properties:

local sky = display.newImage ("sky.png", 100, 200) sky.anchorX = 0 sky.anchorY = 0

The anchor values go from 0 to 1.  

For anchorX: 0 is the left edge, 1 is the right edge and therefore 0.5 is the middle (and is the default value).

For anchorY: 0 is the top edge, 1 is the bottom and again 0.5 is the middle.