Autoscaling cords seem to be off.

Hi,

I just started using corona, and for the love of god i can’t seem to figure out how to make the content area match the actual coordinates.

When i did the basic tutorials, or even when i load the shipped example scripts, the coordinates seem to be off. What i’m experiencing is that the coordinate for 0,0 is off screen. My top left corner seems to be around 75,75. When i did the " hello world " example, i had to increment the coordinates to see the full text, or i would only see the bottom left corner of the “world” text.

This is in a completely new installation, with nothing changed…

How do i fix this?

Hi,

When I run this code it sticks to corner even after the scale, as it should:

local rect = display.newRect(0,0, 640, 200) rect.anchorX = 0 rect.anchorY = 0 rect:scale(0.5, 0.5)

A note is that setReferencePoint is not being used in v2, instead Corona uses anchor points:

http://docs.coronalabs.com/api/type/DisplayObject/anchorX.html

Best regards,

Tomas

Hi Tomas

Hmm, strangely enough, this seems to stick to the corner. Is newText objects anchored in the center? Maybe this is whats causing the problem i’m seeing.

That’s definitely it, after setting the text anchor, everything is fine. Thank you Tomas! :smiley:

This code works for me:

local myText = display.newText( "Hello World!", 0, 0, native.systemFont, 50 ) myText.anchorX = 0.5 myText.anchorY = 0.5 

What you need to know is that anchorX and anchorY sets the anchor points so in the code above relatively to the object and also that anchorX and anchorY uses a value between 0.0 - 1.0 i.e. not 100 pixels in or something like that which I thought first.

With the code above the anchorX is in the middle of the text object (on the width) and the anchorY is in the middle of the object (on the height) so I only see the the bottom corner (1/4) which is correct.

Best regards,

Tomas

Also when I scales the object it looks good.

Best regards,

Tomas

Yeah, this scaling stuff is totally new to me, i usually had to make the scaling stuff myself in the old programs i made :smiley: Just had to wrap my brain around it.

Thank you again!

All display objects, are now by default referenced from their center, so creating a rectangle:  display.newRect(0,0,100,100) will center a 100,100 rectangle on 0,0.  The display.newText() has the same behavior.

Rob

Maybe you should update your beginner tutorials to reflect this, its kinda confusing for a newbie like me when its looking all wrong :slight_smile:

Can you provide the link to the tutorial that is wrong?

Thanks

Rob

Hi Rob,

Sure: http://docs.coronalabs.com/guide/start/helloWorld/index.html this one need some anchor info on it, or the text will be half off screen.

I think you caught this in the middle of us updating.  I just looked at the docs and it isn’t positioning at 0,0, but 50,50.

Just as a side note, while we are combing our documentation, there are plenty of blogs, tutorials, videos, books and such done by 3rd party providers who we can’t control how fast they update their tutorials.  So the best we can do is to try and educate people that there is a difference and be able to react accordingly when viewing older samples.

Rob

Hi Rob,

My mistake, i wasn’t using 0,0 but 50,50 when i first tried it, and that made my " hello world " text wrap off the screen on my simulator screen. If fact, if i copy the code

local myTextObject = display.newText( "Hello World!", 50, 50, "Arial", 60 )  

and run it, all i see on my simulator screen is “o world!”

I’m only mentioning this as i believe a newbie tutorial meant as a quick introduction, ought to be flawless, so it won’t scare newbies off :slight_smile:

Okay, I’ll get it fixed.

Rob

Hi,

When I run this code it sticks to corner even after the scale, as it should:

local rect = display.newRect(0,0, 640, 200) rect.anchorX = 0 rect.anchorY = 0 rect:scale(0.5, 0.5)

A note is that setReferencePoint is not being used in v2, instead Corona uses anchor points:

http://docs.coronalabs.com/api/type/DisplayObject/anchorX.html

Best regards,

Tomas

Hi Tomas

Hmm, strangely enough, this seems to stick to the corner. Is newText objects anchored in the center? Maybe this is whats causing the problem i’m seeing.

That’s definitely it, after setting the text anchor, everything is fine. Thank you Tomas! :smiley:

This code works for me:

local myText = display.newText( "Hello World!", 0, 0, native.systemFont, 50 ) myText.anchorX = 0.5 myText.anchorY = 0.5 

What you need to know is that anchorX and anchorY sets the anchor points so in the code above relatively to the object and also that anchorX and anchorY uses a value between 0.0 - 1.0 i.e. not 100 pixels in or something like that which I thought first.

With the code above the anchorX is in the middle of the text object (on the width) and the anchorY is in the middle of the object (on the height) so I only see the the bottom corner (1/4) which is correct.

Best regards,

Tomas

Also when I scales the object it looks good.

Best regards,

Tomas

Yeah, this scaling stuff is totally new to me, i usually had to make the scaling stuff myself in the old programs i made :smiley: Just had to wrap my brain around it.

Thank you again!