Type Function Object DisplayObject Library display.* Return value none Revision Release 2023.3686 Keywords scale See also object.xScale object.yScale
Effectively multiplies the size of a display object by
yScale respectively. The scaling occurs around the object's anchor point.
Valid examples include
1.0 for 100%,
2.0 for 200%, or
0.5 for 50%.
You can flip a display object horizontally or vertically by passing a negative value to object:scale() as seen in the example below.
Changing the scale factor of a display object is not reflected in the object.width or object.height properties of the object. Only object.contentWidth and object.contentHeight are affected.
When a display object is converted into a physics object, scaling the object will change the visual size, but it will not affect how the physics engine regards the object size. This could result in unpredictable results when interacting with other physics bodies.
object:scale( xScale, yScale )
Numbers. Factors by which to change the scale in the x and y directions respectively.
local star = display.newImage( "star.png" ) -- Scale the image by 200% (x) and 50% (y) star:scale( 2, 0.5 )
local star = display.newImage( "star.png" ) -- Flip the image vertically and horizontally star:scale( -1, -1 )