Skip to main content

CCLayerMultiGradient

CCLayerMultiGradient

Cocos2D

A gradient layer that supports multiple color stops, rendered using CCDrawNode strips. Unlike CCLayerGradient (which only supports 2 colors), this supports any number of color stops for rich background gradients. Usage: var gradient = new CCLayerMultiGradient( new CCColor4B[] darkBlue, midBlue, purple , new float[] 0f, 0.5f, 1f , width, height); AddChild(gradient);

Inheritance: System.Object → Cocos2D.CCNode → Cocos2D.CCDrawNode

Implements: Cocos2D.ICCSelectorProtocol, Cocos2D.ICCFocusable, Cocos2D.ICCTargetedTouchDelegate, Cocos2D.ICCStandardTouchDelegate, Cocos2D.ICCTouchDelegate, Cocos2D.ICCKeypadDelegate, Cocos2D.ICCKeyboardDelegate, Cocos2D.ICCRGBAProtocol, System.Collections.Generic.IComparer{Cocos2D.CCNode}

Constructors

CCLayerMultiGradient(CCColor4B[], float[], float, float, bool)

CCLayerMultiGradient(CCColor4B[], float[], float, float, bool)(Cocos2D.CCColor4B[] colors, System.Single[] positions, System.Single width, System.Single height, System.Boolean vertical)

Creates a multi-stop gradient layer.

Parameters:
colors (Cocos2D.CCColor4B[]) - Array of colors at each stop.
positions (System.Single[]) - Array of stop positions (0.0 to 1.0), must match colors array length.
width (System.Single) - Width of the gradient layer.
height (System.Single) - Height of the gradient layer.
vertical (System.Boolean) - If true, gradient flows bottom-to-top. If false, left-to-right.
Example

Methods

SetGradient(CCColor4B[], float[])

SetGradient(CCColor4B[], float[])(Cocos2D.CCColor4B[] colors, System.Single[] positions)

Updates the gradient colors and positions. Call this to change the gradient dynamically.

Parameters:
colors (Cocos2D.CCColor4B[])
positions (System.Single[])
Example

SetSize(float, float)

SetSize(float, float)(System.Single width, System.Single height)

Updates the gradient size.

Parameters:
width (System.Single)
height (System.Single)
Example