object.contentHeight

Description:

The height of the object in stage coordindates.

This is similar to object.height except it's value is affected by Y-scaling and rotation.

This is equivalent to object.stageHeight, which has been deprecated.

Syntax:

object.contentHeight

Example:

local rect = display.newRect(100, 100, 50, 50)
rect:setFillColor(170, 170, 170)
 
print("contentHeight: ".. rect.contentHeight) -- contentHeight: 50

Parameters:

 

Returns:

number: Value of the object's height in stage coordinates.

Note: This value may not be the same as object.height if the object has been scaled or rotated.

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

developerdave
User offline. Last seen 1 year 29 weeks ago. Offline
Joined: 19 May 2012

1
2
3
4
5
6
7
8
-- Corona API modifies .contentWidth, .contentHeight according to scale
-- but also to rotation.
-- Often this gives unexpected results, particularly with circles.
-- This alternative method manually multiplies .width, .height by .xScale, .yScale and returns
-- those values, unaffected by rotation.
function ContentSize(o)
    return o.width*o.xScale, o.height*o.yScale;
end