object.height

Description:

Retrieve or change the height of a display object. It's possible to use this to set the height of objects, with the exception of text objects.

For images, the returned parameter is the original bit map height

This parameter is unaffected by object:scale() or object.yScale. (See object.contentHeight.)

Syntax:

local var = object.height
object.height = value

Example:

local rect1 = display.newRect(100, 100, 50, 50)
rect1:setFillColor(170, 170, 170)
 
local rect2 = display.newRect(100, 100, 50, 50)
rect2:setFillColor(255, 255, 255)
rect2.y = rect1.y + rect1.height + 1

Returns:

number: Height value of the object.

Remarks:

The value is not affected by object scaling or rotation.

Note: Setting a new height or width of a display object will always expand or shrink the object from the center no matter what display.setReferencePoint value is set. Case #677/1222

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

personalnadir
User offline. Last seen 33 weeks 2 days ago. Offline
Joined: 24 Nov 2010

It seems like it's also not possible to set the width/height of Groups either.

Tom
User offline. Last seen 1 hour 10 min ago. Offline
Staff
Joined: 13 Jul 2010

The height and width of a group is determined by the objects in the group. You can read the group's height and width but can't set it directly.