Cocos Creator API

1.4.x

Cocos Creator is a highly customizable game development tool that utilizes the power of cocos2d-x.

Color

Extends ValueType
Module: cc

Representation of RGBA colors.

Each color component is a floating point value with a range from 0 to 255.

You can also use the convenience method cc.color to create a new Color.

Properties

WHITE Color static

Solid white, RGBA is [255, 255, 255, 255].

BLACK Color static

Solid black, RGBA is [0, 0, 0, 255].

TRANSPARENT Color static

Transparent, RGBA is [0, 0, 0, 0].

GRAY Color static

Grey, RGBA is [127.5, 127.5, 127.5].

RED Color static

Solid red, RGBA is [255, 0, 0].

GREEN Color static

Solid green, RGBA is [0, 255, 0].

BLUE Color static

Solid blue, RGBA is [0, 0, 255].

YELLOW Color static

Yellow, RGBA is [255, 235, 4].

ORANGE Color static

Orange, RGBA is [255, 127, 0].

CYAN Color static

Cyan, RGBA is [0, 255, 255].

MAGENTA Color static

Magenta, RGBA is [255, 0, 255].

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

Methods

Color
(
  • [r =0]
  • [g =0]
  • [b =0]
  • [a =255]
)
Color

name type description
r optional Number 0

red component of the color, default value is 0.

g optional Number 0

green component of the color, defualt value is 0.

b optional Number 0

blue component of the color, default value is 0.

a optional Number 255

alpha component of the color, default value is 255.

returns:

type: Color

clone ( ) Color

Clone a new color from the current color.

returns:

type: Color

Newly created color.

examples:

var color = new cc.Color();
var newColor = color.clone();// Color {r: 0, g: 0, b: 0, a: 255}

equals
(
  • other
)
Boolean

TODO

name type description
other Color
  • r Number optional , default: 0

    red component of the color, default value is 0.

  • g Number optional , default: 0

    green component of the color, defualt value is 0.

  • b Number optional , default: 0

    blue component of the color, default value is 0.