CCColor Class Reference
| Inherits from | NSObject |
| Declared in | CCColor.h |
Overview
A CCColor object represents color and sometimes opacity (alpha value) for use with Cocos2D objects.
Tasks
Creating a CCColor Object from Component Values
-
+ colorWithWhite:alpha: -
+ colorWithRed:green:blue:alpha: -
+ colorWithRed:green:blue: -
+ colorWithCGColor: -
– colorWithAlphaComponent: -
+ colorWithUIColor:
Initializing a CCColor Object
-
– initWithWhite:alpha: -
– initWithRed:green:blue:alpha: -
– initWithRed:green:blue: -
– initWithCGColor: -
– initWithUIColor:
Creating a CCColor with Preset Component Values
-
+ blackColor -
+ darkGrayColor -
+ lightGrayColor -
+ whiteColor -
+ grayColor -
+ redColor -
+ greenColor -
+ blueColor -
+ cyanColor -
+ yellowColor -
+ magentaColor -
+ orangeColor -
+ purpleColor -
+ brownColor -
+ clearColor
Accessing Color Attributes
Color Helpers
Properties
CGColor
The Quartz color reference that corresponds to the CCColor color.
@property (nonatomic, readonly) CGColorRef CGColorDeclared In
CCColor.hClass Methods
blackColor
Returns a color object whose RGB values are 0.0, 1.0, and 1.0 and whose alpha value is 1.0.
+ (CCColor *)blackColorReturn Value
The CCColor object.
Declared In
CCColor.hblueColor
Returns a color object whose RGB values are 0.0, 0.0, and 1.0 and whose alpha value is 1.0.
+ (CCColor *)blueColorReturn Value
The CCColor object.
Declared In
CCColor.hbrownColor
Returns a color object whose RGB values are 0.6, 0.4, and 0.2 and whose alpha value is 1.0.
+ (CCColor *)brownColorReturn Value
The CCColor object.
Declared In
CCColor.hclearColor
Returns a color object whose RGB values are 0.0, 0.0, and 0.0 and whose alpha value is 0.0.
+ (CCColor *)clearColorReturn Value
The CCColor object.
Declared In
CCColor.hcolorWithCGColor:
Creates and returns a color object using the specified Quartz color reference.
+ (CCColor *)colorWithCGColor:(CGColorRef)cgColorParameters
- cgColor
A reference to a Quartz color.
Return Value
The color object.
Declared In
CCColor.hcolorWithRed:green:blue:
Creates and returns a color object using the specified opacity and RGB component values. Alpha will default to 1.0.
+ (CCColor *)colorWithRed:(float)red green:(float)green blue:(float)blueParameters
- red
The red component of the color object, specified as a value from 0.0 to 1.0.
- green
The green component of the color object, specified as a value from 0.0 to 1.0.
- blue
The blue component of the color object, specified as a value from 0.0 to 1.0.
Return Value
The color object.
Declared In
CCColor.hcolorWithRed:green:blue:alpha:
Creates and returns a color object using the specified opacity and RGBA component values.
+ (CCColor *)colorWithRed:(float)red green:(float)green blue:(float)blue alpha:(float)alphaParameters
- red
The red component of the color object, specified as a value from 0.0 to 1.0.
- green
The green component of the color object, specified as a value from 0.0 to 1.0.
- blue
The blue component of the color object, specified as a value from 0.0 to 1.0.
- alpha
The opacity value of the color object, specified as a value from 0.0 to 1.0.
Return Value
The color object.
Declared In
CCColor.hcolorWithUIColor:
Converts a UIColor object to its CCColor equivalent.
+ (CCColor *)colorWithUIColor:(UIColor *)colorParameters
- color
UIColor object.
Return Value
The color object.
Declared In
CCColor.hcolorWithWhite:alpha:
Creates and returns a color object using the specified opacity and grayscale values.
+ (CCColor *)colorWithWhite:(float)white alpha:(float)alphaParameters
- white
The grayscale value of the color object, specified as a value from 0.0 to 1.0.
- alpha
The opacity value of the color object, specified as a value from 0.0 to 1.0.
Return Value
The color object.
Declared In
CCColor.hcyanColor
Returns a color object whose RGB values are 0.0, 1.0, and 1.0 and whose alpha value is 1.0..
+ (CCColor *)cyanColorReturn Value
The CCColor object.
Declared In
CCColor.hdarkGrayColor
Returns a color object whose grayscale value is 1/3 and whose alpha value is 1.0.
+ (CCColor *)darkGrayColorReturn Value
The CCColor object.
Declared In
CCColor.hgrayColor
Returns a color object whose grayscale value is 0.5 and whose alpha value is 1.0.
+ (CCColor *)grayColorReturn Value
The CCColor object.
Declared In
CCColor.hgreenColor
Returns a color object whose RGB values are 0.0, 1.0, and 0.0 and whose alpha value is 1.0.
+ (CCColor *)greenColorReturn Value
The CCColor object.
Declared In
CCColor.hlightGrayColor
Returns a color object whose grayscale value is 2/3 and whose alpha value is 1.0.
+ (CCColor *)lightGrayColorReturn Value
The CCColor object.
Declared In
CCColor.hmagentaColor
Returns a color object whose RGB values are 1.0, 0.0, and 1.0 and whose alpha value is 1.0.
+ (CCColor *)magentaColorReturn Value
The CCColor object.
Declared In
CCColor.horangeColor
Returns a color object whose RGB values are 1.0, 0.5, and 0.0 and whose alpha value is 1.0..
+ (CCColor *)orangeColorReturn Value
The CCColor object.
Declared In
CCColor.hpurpleColor
Returns a color object whose RGB values are 0.5, 0.0, and 0.5 and whose alpha value is 1.0.
+ (CCColor *)purpleColorReturn Value
The CCColor object.
Declared In
CCColor.hredColor
Returns a color object whose RGB values are 1.0, 0.0, and 0.0 and whose alpha value is 1.0.
+ (CCColor *)redColorReturn Value
The CCColor object.
Declared In
CCColor.hwhiteColor
Returns a color object whose grayscale value is 1.0 and whose alpha value is 1.0.
+ (CCColor *)whiteColorReturn Value
The CCColor object.
Declared In
CCColor.hyellowColor
Returns a color object whose RGB values are 1.0, 1.0, and 0.0 and whose alpha value is 1.0.
+ (CCColor *)yellowColorReturn Value
The CCColor object.
Declared In
CCColor.hInstance Methods
colorWithAlphaComponent:
Creates and returns a color object that has the same color space and component values as the receiver, but has the specified alpha component.
- (CCColor *)colorWithAlphaComponent:(float)alphaParameters
- alpha
The opacity value of the new CCColor object.
Return Value
The color object.
Declared In
CCColor.hinitWithCGColor:
Initializes and returns a color object using the specified Quartz color reference.
- (CCColor *)initWithCGColor:(CGColorRef)cgColorParameters
- cgColor
A reference to a Quartz color.
Return Value
An initialized color object.
Declared In
CCColor.hinitWithRed:green:blue:
Initializes and returns a color object using the specified opacity and RGB component values. Alpha will default to 1.0.
- (CCColor *)initWithRed:(float)red green:(float)green blue:(float)blueParameters
- red
The red component of the color object, specified as a value from 0.0 to 1.0.
- green
The green component of the color object, specified as a value from 0.0 to 1.0.
- blue
The blue component of the color object, specified as a value from 0.0 to 1.0.
Return Value
An initialized color object.
Declared In
CCColor.hinitWithRed:green:blue:alpha:
Initializes and returns a color object using the specified opacity and RGBA component values.
- (CCColor *)initWithRed:(float)red green:(float)green blue:(float)blue alpha:(float)alphaParameters
- red
The red component of the color object, specified as a value from 0.0 to 1.0.
- green
The green component of the color object, specified as a value from 0.0 to 1.0.
- blue
The blue component of the color object, specified as a value from 0.0 to 1.0.
- alpha
The opacity value of the color object, specified as a value from 0.0 to 1.0.
Return Value
An initialized color object.
Declared In
CCColor.hinitWithUIColor:
Initializes and returns a UIColor object to its CCColor equivalent.
- (CCColor *)initWithUIColor:(UIColor *)colorParameters
- color
UIColor object.
Return Value
An initialized color object.
Declared In
CCColor.hinitWithWhite:alpha:
Initializes and returns a color object using the specified opacity and grayscale values.
- (CCColor *)initWithWhite:(float)white alpha:(float)alphaParameters
- white
The grayscale value of the color object, specified as a value from 0.0 to 1.0.
- alpha
The opacity value of the color object, specified as a value from 0.0 to 1.0.
Return Value
An initialized color object.
Declared In
CCColor.hinterpolateTo:alpha:
Linearly interpolate from this color to ‘toColor’. Parameter alpha is normalised
- (CCColor *)interpolateTo:(CCColor *)toColor alpha:(float)alphaReturn Value
The interpolated color.
Declared In
CCColor.h