FusePowered

object.alpha

Description:

Retrieve or set the object's opacity. A value of 0 is transparent and 1.0 is opaque.

This property is often used in transition.to method to fade in/out an object over time.

Note that this is a different alpha property than the optional "alpha" component found in each color specification of the form (r, g, b [, a]). In the latter case, the alpha range is 0-255, just like the red, green and blue ranges, because the resulting value set specifies a 32-bit color with 8 bits per channel.

Syntax:

local value = object.alpha
object.alpha = value

Example:

local rect1 = display.newRect(100, 100, 50, 50)
rect1:setFillColor(127, 127, 127)
 
local rect2 = display.newRect(125, 125, 50, 50)
rect2:setFillColor(255, 255, 255)
rect2.alpha = 0.5

Parameters:

number: alpha value (0 to 1.0)

Returns:

number: alpha value (0 to 1.0)

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