display.contentCenter, display.contentWidth, and their variations

hi guys, I have learned corona in my free time over the past few weeks. i actually have had this confusion from the start but i didn’t pay much attention to it until now but i think better to just ask this question to you guys. It’s about the display.contentCenter and display.contentWidth and their variations

Usually when I put an image into my test app, I would do something like this:

local imageMegaman = display.newImageRect ( "megaman.jpg", 250, 200) imageMegaman.x = 250 imageMegaman.y = 300

but when I compare with sample codes from Corona, I see they “avoid” using numbers for x and y placement. Instead i find codes like display.contentCenterX, display.contentCenterY, display.contentWidth / 4, and so on.  My questions:

  1. I do know display.contentCenterX and Y means the image will be automatically placed in the middle of the screen but is there any specific reason why should I use it instead of just use the number?

My speculation is that with “display.contentCenter” it will be always placed in the middle of the screen no matter what the screen resolution is in the device. While maybe with using numbers for the x and y, they will be placed “differently” in different devices. Am I right?

  1. Another question, how if I want the image to be placed like at the bottom part of the screen? Is there any specific tutorial page for this? I see the samples using code like display.contentWidth / 4 and this kind of stuffs, but I dont understand what does this code mean…for example, display.contentWidth / 2 will put the image a bit below display.contentWidth / 4 , why is that? And again, how to place the image at the middle-to-bottom part of the screen? No matter what number I use, the image is always placed at the middle-to-top part of the screen

  2. I’m currently learning scrollView and I am already able to insert image to the scrollview feature. I use this code:

    local imageMegaman = display.newImageRect ( “megaman.jpg”, 250, 200) imageMegaman.x = display.contentCenterX imageMegaman.y = 600 – insert scrollView to imageMegaman scrollView:insert ( imageMegaman )

with this, the Megaman image won’t be instantly seen on the screen as “600” is located below the screen but of course when I “scroll” down, I can finally see the Megaman image.

now related to the questions above, what code should I use to replace this number 600? I mean the code stuff like display.contentWidth something because I assume this code can’t put image “below” the screen like if I use number?

  1. very simple question, is there anything else that I can use to replace these numbers 250, 200 in the above code sample? I mean inside the code:

    display.newImageRect ( “megaman.jpg”, 250, 200 )

I know 250 and 200 represent width and height but is there any code like the display.contentWidth stuff that I can use to replace this?

Thanks guys. in short what I want to know is if there’s any difference between using number and display.contentWidth, display.contentCenter, and their variations. and if there’s, what should I use to replace that number “600” for y position in the scrollView part, that’s all.