object.yReference

Description:

Retrieve or change the y-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. Conceptually, the reference point is the location about which scaling and rotations occur. Sometimes this is referred to as the registration point. For most display objects, this value defaults to 0, meaning the y-position of the origin and the reference point are the same. This merely defines the reference point, so changing the value of this property does not change the position of the object.

Syntax:

local var = object.yReference
object.yReference = value

Example:

display.setStatusBar( display.HiddenStatusBar ) 
 
--place a white square on the screen
local rect = display.newRect(135, 50, 50, 50)
rect:setFillColor(255, 255, 255)
 
--change the square's yReference
rect.yReference = 25
 
--show the square's reference point as a red dot
local dot = display.newCircle(0, 0, 6)
dot:setFillColor(255, 0, 0)
dot.x = rect.x
dot.y = rect.y

display.setStatusBar( display.HiddenStatusBar ) 
 
--place a grey square on the screen at 0, 0
local rect1 = display.newRect(0, 0, 50, 50)
rect1:setFillColor(170, 170, 170)
 
--place a white square on the screen at 0, 0
local rect2 = display.newRect(0, 0, 50, 50)
rect2:setFillColor(255, 255, 255)
 
--change the white square's yReference
rect2.yReference = 25
 
--move both squares to 160, 100
rect1.x, rect1.y = 160, 100
rect2.x, rect2.y = 160, 100
 
--show the white square's reference point as a red dot
local dot = display.newCircle(0, 0, 6)
dot:setFillColor(255, 0, 0)
dot.x = rect2.x
dot.y = rect2.y

Returns:

number: The Y-reference value for the object.

Remarks:
Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Corona SDK 1.0
  • Windows:
    Corona SDK 2.0
  • iOS:
    Corona SDK 1.0
  • Android:
    Corona SDK 2.0

Replies

info756
User offline. Last seen 2 years 20 weeks ago. Offline
Joined: 7 Mar 2012

Instead of:

Retrieve or change the y-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.

it should say:

Retrieve or change the y-position of the reference point relative to the object’s local origin.

(taken from http://developer.anscamobile.com/forum/2011/05/22/confusing-documentation)