Inherits from CCNodeColor : CCNode : CCResponder : NSObject
Declared in CCNodeColor.h

Overview

CCNodeGradient is a subclass of CCNodeColor that draws gradients across the background.

All features from CCNodeColor 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.

Tasks

Creating a CCNodeGradient Object

Initializing a CCNodeGradient Object

Accessing CCNodeGradient Attributes

Properties

compressedInterpolation

Deprecated in 3.1. All colors are correctly displayed across the node's rectangle.

Default: YES.

@property (nonatomic, readwrite) BOOL compressedInterpolation

Declared In

CCNodeColor.h

endColor

The ending color.

@property (nonatomic, strong) CCColor *endColor

Declared In

CCNodeColor.h

endOpacity

The ending color.

@property (nonatomic, readwrite) CGFloat endOpacity

Declared In

CCNodeColor.h

startColor

The starting color.

@property (nonatomic, strong) CCColor *startColor

Declared In

CCNodeColor.h

startOpacity

The starting opacity.

@property (nonatomic, readwrite) CGFloat startOpacity

Declared In

CCNodeColor.h

vector

The vector along which to fade color.

@property (nonatomic, readwrite) CGPoint vector

Declared In

CCNodeColor.h

Class Methods

nodeWithColor:fadingTo:

Creates a full-screen CCNode with a gradient between start and end color values.

+ (id)nodeWithColor:(CCColor *)start fadingTo:(CCColor *)end

Parameters

start

Start color.

end

End color.

Return Value

The CCNodeGradient Object.

Declared In

CCNodeColor.h

nodeWithColor:fadingTo:alongVector:

Creates a full-screen CCNode with a gradient between start and end color values with gradient direction vector.

+ (id)nodeWithColor:(CCColor *)start fadingTo:(CCColor *)end alongVector:(CGPoint)v

Parameters

start

Start color.

end

End color.

v

Direction vector for gradient.

Return Value

The CCNodeGradient Object.

Declared In

CCNodeColor.h

Instance Methods

initWithColor:fadingTo:

Initializes a full-screen CCNode with a gradient between start and end color values.

- (id)initWithColor:(CCColor *)start fadingTo:(CCColor *)end

Parameters

start

Start color.

end

End color.

Return Value

An initialized CCNodeGradient Object.

Declared In

CCNodeColor.h

initWithColor:fadingTo:alongVector:

Creates a full-screen CCNode with a gradient between start and end color values with gradient direction vector.

- (id)initWithColor:(CCColor *)start fadingTo:(CCColor *)end alongVector:(CGPoint)v

Parameters

start

Start color.

end

End color.

v

Direction vector for gradient.

Return Value

An initialized CCNodeGradient Object.

Declared In

CCNodeColor.h