object:scale()

Type Function
Object DisplayObject
Library display.*
Return value none
Revision Release 2022.3683
Keywords scale
See also object.xScale
object.yScale

Overview

Effectively multiplies the size of a display object by xScale and 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.

Gotchas

Syntax

object:scale( xScale, yScale )
xScale, yScale (required)

Numbers. Factors by which to change the scale in the x and y directions respectively.

Examples

Normal Scaling
local star = display.newImage( "star.png" )

-- Scale the image by 200% (x) and 50% (y)
star:scale( 2, 0.5 )
Image Flip
local star = display.newImage( "star.png" )

-- Flip the image vertically and horizontally
star:scale( -1, -1 )