Reputation: 162
I'm using corona simulator. I displayed display.contentWidth and display.contentHeight .The width is 320 and height is 480. I've also made a text saying "Hello", and played with positioning.
I've noticed the x values looked pretty accurate, I would set x value of text to 0 and the center of it would be half covered and half revealed. Same results for x value of 320, but on the other side of the phone simulator.
When I set y value to 0 it sits right under the Carrier and fake signal strength symbol, fully revealed. When I set the y value to 480 the heights max, it would have about an inch gap from the bottom of the phone. -- My thoughts are that it should be half covered vertically both ways :-S
In corona simulator i'm viewing it in Iphone5 , and notice when I change to Iphone it would reveal as I would expect. With Iphone 5, droid, and some other view it would give me these results.
* My question is would my program look the same on all devices, or is corona simulator accurate displaying what it would look like. If it displays different on variety of devices, Why?
width = display.newText (display.contentWidth .. "px is Width", 200, 200, nil, 30)
height = display.newText (display.contentHeight .. "px is Height", 150,300, nil, 30)
text = display.newText ("Hello", 0, 480, nil, 30)
Upvotes: 2
Views: 1983
Reputation: 7390
Every object has a rectangular boundary as in figure 1 below. Here there is a text object with boundary indicated with black colour.
The red dot
at the top is that objects default anchor point.
If you are not specifying the text's x and y positions as (obj.x=... & obj.y=...), then corona will position the object according to the points in the display object creation line (i.e.., display.newText(""......)
). For example, if you have a code like:
local text = display.newText ("myText", 0, 0, nil, 30)
then the text will be placed such that the red dot is at (0,0). It is why you saw it under the status bar.
General object placement in corona is as below:
Underlined myText
indicates the different positioning of the text object according to points in object creation line. i.e.;
local text = display.newText("myText",x,y,nil,30)
_w ==> display.contentWidth
_h ==> display.contentHeight
Keep Coding.................. :)
Upvotes: 2
Reputation: 728
The resolution of the iPhone 5 is different to the iPhone 4 (obviously), but rather than receiving different display.content* values, Corona handles it using something called display.screenOrigin. This is the difference between the display being used and the standard display (iPhone/iPhone 4). If you print these values, for example:
print("Origin x = "..tostring(display.screenOriginX))
print("Origin y = "..tostring(display.screenOriginY))
Then you will see that one of them, depending on your simulator's orientation, will be "-44". This is the difference in pixels. In your example for what I assume is the portrait orientation, you would need to position Y for top and bottom like so:
--For positioning at 'true 0'
obj.y = 0 + (display.screenOriginY)
--Or, for positioning at "true bottom"
obj.y = 0 - (display.screenOriginY)
Hope this helps. For more on display.screenOrigin, see the Corona documentation for X and the Corona documentation for Y
Cush
Upvotes: 2