Class cc.LayerGradient

Class Summary
Constructor Attributes Constructor Name and Description
 

CCLayerGradient is a subclass of cc.LayerColor that draws gradients across the background.

Method Summary

Class Detail

cc.LayerGradient()

CCLayerGradient is a subclass of cc.LayerColor that draws gradients across the background.

All features from cc.LayerColor are valid, plus the following new features:

  • direction
  • final color
  • interpolation mode

Color is interpolated between the startColor and endColor along the given
vector (starting at the origin, ending at the terminus). If no vector is
supplied, it defaults to (0, -1) -- a fade from top to bottom.

If 'compressedInterpolation' is disabled, you will not see either the start or end color for
non-cardinal vectors; a smooth gradient implying both end points will be still
be drawn, however.

If 'compressedInterpolation' is enabled (default mode) you will see both the start and end colors of the gradient.

Field Detail

{Number} compresseInterpolation
- Indicate whether or not the interpolation will be compressed
{cc.Color} endColor
- End color of the color gradient
{Number} endOpacity
- End opacity of the color gradient
{cc.Color} startColor
- Start color of the color gradient
{Number} startOpacity
- Start opacity of the color gradient
{Number} vector
- Direction vector of the color gradient

Method Detail

  • <static> {cc.LayerGradient} cc.LayerGradient.create(start, end, v)
    creates a gradient layer
    Parameters:
    {cc.Color} start
    starting color
    {cc.Color} end
    ending color
    {cc.Point|Null} v
    Returns:
    {cc.LayerGradient}
  • {cc.Color} getEndColor()
    get the end color
    Returns:
    {cc.Color}
  • {Number} getEndOpacity()
    get the end gradient opacity
    Returns:
    {Number}
  • {cc.Color} getStartColor()
    get the starting color
    Returns:
    {cc.Color}
  • {Number} getStartOpacity()
    get the starting gradient opacity
    Returns:
    {Number}
  • {cc.Point} getVector()
    Returns:
    {cc.Point}
  • {Boolean} init(start, end, v)
    Parameters:
    {cc.Color} start
    starting color
    {cc.Color} end
    {cc.Point|Null} v
    Returns:
    {Boolean}
  • {Boolean} isCompressedInterpolation()
    is Compressed Interpolation
    Returns:
    {Boolean}
  • setCompressedInterpolation(compress)
    Parameters:
    {Boolean} compress
  • setContentSize(size, height)
    Sets the untransformed size of the LayerGradient.
    Parameters:
    {cc.Size|Number} size
    The untransformed size of the LayerGradient or The untransformed size's width of the LayerGradient.
    {Number} height Optional
    The untransformed size's height of the LayerGradient.
  • setEndColor(color)
    set the end gradient color
    // Example
    myGradientLayer.setEndColor(cc.color(255,0,0));
    //set the ending gradient to red
    Parameters:
    {cc.Color} color
  • setEndOpacity(o)
    set the end gradient opacity
    Parameters:
    {Number} o
  • setStartColor(color)
    set the starting color
    // Example
    myGradientLayer.setStartColor(cc.color(255,0,0));
    //set the starting gradient to red
    Parameters:
    {cc.Color} color
  • setStartOpacity(o)
    set starting gradient opacity
    Parameters:
    {Number} o
    from 0 to 255, 0 is transparent
  • setVector(Var)
    set vector
    Parameters:
    {cc.Point} Var