object.y

Type Number
Object DisplayObject
Library display.*
Revision Release 2024.3703
Keywords y, position
See also object.x

Overview

Specifies the y position (in local coordinates) of the object relative to its parent — specifically, the y position of the object's anchorY point relative to its parent. Changing this value will move the object in the y direction.

Gotchas

This cannot be used on a physical body during a collision event. However, your collision handler may set a flag or include a time delay via timer.performWithDelay() so that the action can occur in the next application cycle or later. See the Collision Detection guide for a complete list of which APIs and methods are subject to this rule.

Example

local rect = display.newRect( 0, 0, 50, 50 )
rect:setFillColor( 1, 1, 1 )

rect.y = 100