Class cc.LayerGradient
- Defined in: CCLayer.js
- Extends cc.LayerColor
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.
Method Detail
-
creates a gradient layer
- Parameters:
- {cc.Color3B} start
- starting color
- {cc.Color3B} end
- ending color
- {cc.Point|Null} v
- Returns:
- {cc.LayerGradient}
-
ctor()Constructor
-
{cc.Color3B} getEndColor()get the end color
- Returns:
- {cc.Color3B}
-
{Number} getEndOpacity()get the end gradient opacity
- Returns:
- {Number}
-
{cc.Color3B} getStartColor()get the starting color
- Returns:
- {cc.Color3B}
-
{Number} getStartOpacity()get the starting gradient opacity
- Returns:
- {Number}
-
{cc.Point} getVector()
- Returns:
- {cc.Point}
-
{Boolean} init(start, end, v)
- Parameters:
- {cc.Color4B} start
- starting color
- {cc.Color4B} 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.c3b(255,0,0)); //set the ending gradient to red
- Parameters:
- {cc.Color3B} color
-
setEndOpacity(o)set the end gradient opacity
- Parameters:
- {Number} o
-
setStartColor(color)set the starting color
// Example myGradientLayer.setStartColor(cc.c3b(255,0,0)); //set the starting gradient to red
- Parameters:
- {cc.Color3B} 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