Class cc.LayerGradient
- Defined in: CCLayer.js
- Extends cc.LayerColor
Constructor Attributes | Constructor Name and Description |
---|---|
cc.LayerGradient(start, end, v)
CCLayerGradient is a subclass of cc.LayerColor that draws gradients across the background. |
Method Summary
Class Detail
cc.LayerGradient(start, end, v)
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
-
Creates a gradient layer
- Deprecated:
- since v3.0, please use the new construction instead
- Returns:
- {cc.LayerGradient}
- See:
- cc.layerGradient
-
ctor(start, end, v)Constructor of cc.LayerGradient
-
{cc.Color} getEndColor()Returns the end color
- Returns:
- {cc.Color}
-
{Number} getEndOpacity()Returns the end gradient opacity
- Returns:
- {Number}
-
{cc.Color} getStartColor()Returns the starting color
- Returns:
- {cc.Color}
-
{Number} getStartOpacity()Returns the starting gradient opacity
- Returns:
- {Number}
-
{cc.Point} getVector()Returns the direction vector of the gradient
- Returns:
- {cc.Point}
-
{Boolean} init(start, end, v)Initialization of the layer, please do not call this function by yourself, you should pass the parameters to constructor to initialize a layer
- Returns:
- {Boolean}
-
{Boolean} isCompressedInterpolation()Returns whether compressed interpolation is enabled
- Returns:
- {Boolean}
-
setCompressedInterpolation(compress)Sets whether compressed interpolation is enabled
- 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)Sets the end gradient color
// Example myGradientLayer.setEndColor(cc.color(255,0,0)); //set the ending gradient to red
- Parameters:
- {cc.Color} color
-
setEndOpacity(o)Sets the end gradient opacity
- Parameters:
- {Number} o
-
setStartColor(color)Sets the starting color
// Example myGradientLayer.setStartColor(cc.color(255,0,0)); //set the starting gradient to red
- Parameters:
- {cc.Color} color
-
setStartOpacity(o)Sets starting gradient opacity
- Parameters:
- {Number} o
- from 0 to 255, 0 is transparent
-
setVector(Var)Sets the direction vector of the gradient
- Parameters:
- {cc.Point} Var