Type Number Object DisplayObject Library display.* Revision Release 2022.3683 Keywords object, width, size See also object.contentWidth object.height
Retrieve or change the width of a display object. For text objects, this property can be used to get (but not set) the width.
For images, the returned value is the original bitmap width, including any transparent area.
This value is unaffected by object:scale() or object.xScale. Likewise, the value is not affected by object rotation.
local rect1 = display.newRect( 100, 100, 50, 50 ) rect1:setFillColor( 0.5, 0, 1 ) local rect2 = display.newRect( 100, 100, 50, 50 ) rect2:setFillColor( 1, 0, 0 ) rect2.x = rect1.x + rect1.width+10 local rect3 = display.newRect( 75, 150, 50, 50 ) rect3:setFillColor( 0, 0.5, 1 ) rect3.anchorX = 0 transition.to( rect3, { time=2000, width=110 } )