It says:
object.xOrigin: Retrieve or change the x-position of the object’s origin relative to the parent’s origin. It is in the object’s local coordinates.
If it’s relative to the parent’s origin, how could it be in the object’s local coordinates?
object.xOrigin in the object’s local coordinates can only be 0. (zero)
It says:
object.x: Specifies the x-position (in local coordinates) of the object relative to the parent — the parent’s origin to be precise. Specifically, it provides the x-position of the object’s reference point relative to the parent.
I think it should say:
object.x: Specifies the x-position (in the local coordinates of the parent) of the object relative to the parent — the parent’s origin to be precise. Specifically, it provides the x-position of the object’s reference point relative to the parent.
This paragraph also implies object.x/object.y is a way to set the reference point of the object using coordinates defined against the coordinate axes of the parent object, while object.xReference/object.yReference is a way to set the reference point of the object using coordinates defined against the coordinate axes of the object itself.
It says:
object.xReference: Retrieve or change the x-position of the reference point relative to the object’s local origin. It is relative to another point in the object, not to its parent.
I think it should say:
object.xReference: Retrieve or change the x-position of the reference point relative to the object’s local origin.
“another point in the object” is too mysterious and vague for something that needs to be cartesian.
There are other parts in doc where these concepts are presented in various confusing manners.
One thing that will also trip anyone starting with Corona is to realize that:
-
When you create a new group, its origin and reference point are both set to the origin of its parent. In practice, for a top level group, this means the top left corner of the screen.
-
Even though many objects are initially positioned using their top left corner, their origin ends being located at their center. Obviously, circles are different, since they are initially positioned using their center and their origin also ends up being their center.
The following bit of documentation is also confusing:
When an Display Object is created, the origin specifies the TopLeft corner of the object. After the object has been created, the reference point is now the center of the object and the x,y values will reference that point.
This before/after terminology is confusing from a programmatic standpoint. It’s not that “the origin specifies the TopLeft corner of the object”, it’s that the object doesn’t exist yet, so it will be placed using its TopLeft corner. Once the object has been added, it has a position in its parent’s coordinate system which is no longer defined by its TopLeft corner, but by the coordinates of its center, as represented by x and y.
[import]uid: 59054 topic_id: 10337 reply_id: 310337[/import]