Cocos Creator API

1.0.0

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

Enum Macro

Module: cc

Predefined constants

INVALID_INDEX Number readOnly

NODE_TAG_INVALID Number readOnly

Default Node tag

PI Number readOnly

PI is the ratio of a circle's circumference to its diameter.

PI2 Number readOnly

PI * 2

FLT_MAX Number readOnly

Maximum float value

FLT_MIN Number readOnly

Minimum float value

RAD Number readOnly

PI / 180

DEG Number readOnly

One degree

UINT_MAX Number readOnly

Maximum unsigned int value

REPEAT_FOREVER Number readOnly

FLT_EPSILON Number readOnly

ONE Number readOnly

ZERO Number readOnly

SRC_ALPHA Number readOnly

SRC_ALPHA_SATURATE Number readOnly

SRC_COLOR Number readOnly

DST_ALPHA Number readOnly

DST_COLOR Number readOnly

ONE_MINUS_SRC_ALPHA Number readOnly

ONE_MINUS_SRC_COLOR Number readOnly

ONE_MINUS_DST_ALPHA Number readOnly

ONE_MINUS_DST_COLOR Number readOnly

ONE_MINUS_CONSTANT_ALPHA Number readOnly

ONE_MINUS_CONSTANT_COLOR Number readOnly

LINEAR Number readOnly

the constant variable equals gl.LINEAR for texture

BLEND_DST Number readOnly

default gl blend dst function. Compatible with premultiplied alpha images.

WEB_ORIENTATION_PORTRAIT Number readOnly

Device oriented vertically, home button on the bottom (UIDeviceOrientationPortrait)

WEB_ORIENTATION_LANDSCAPE_LEFT Number readOnly

Device oriented horizontally, home button on the right (UIDeviceOrientationLandscapeLeft)

WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN Number readOnly

Device oriented vertically, home button on the top (UIDeviceOrientationPortraitUpsideDown)

WEB_ORIENTATION_LANDSCAPE_RIGHT Number readOnly

Device oriented horizontally, home button on the left (UIDeviceOrientationLandscapeRight)

DEVICE_ORIENTATION_PORTRAIT Number readOnly

Device oriented vertically, home button on the bottom (UIDeviceOrientationPortrait)

DEVICE_ORIENTATION_LANDSCAPE_LEFT Number readOnly

Device oriented horizontally, home button on the right (UIDeviceOrientationLandscapeLeft)

DEVICE_ORIENTATION_PORTRAIT_UPSIDE_DOWN Number readOnly

Device oriented vertically, home button on the top (UIDeviceOrientationPortraitUpsideDown)

DEVICE_ORIENTATION_LANDSCAPE_RIGHT Number readOnly

Device oriented horizontally, home button on the left (UIDeviceOrientationLandscapeRight)

DEVICE_MAX_ORIENTATIONS Number readOnly

In browsers, we only support 2 orientations by change window size.

VERTEX_ATTRIB_FLAG_NONE Number readOnly

VERTEX_ATTRIB_FLAG_POSITION Number readOnly

VERTEX_ATTRIB_FLAG_COLOR Number readOnly

VERTEX_ATTRIB_FLAG_TEX_COORDS Number readOnly

VERTEX_ATTRIB_FLAG_POS_COLOR_TEX Number readOnly

GL_ALL Number readOnly

GL server side states

VERTEX_ATTRIB_POSITION Number readOnly

VERTEX_ATTRIB_COLOR Number readOnly

VERTEX_ATTRIB_TEX_COORDS Number readOnly

VERTEX_ATTRIB_MAX Number readOnly

UNIFORM_PMATRIX Number readOnly

UNIFORM_MVMATRIX Number readOnly

UNIFORM_MVPMATRIX Number readOnly

UNIFORM_TIME Number readOnly

UNIFORM_SINTIME Number readOnly

UNIFORM_COSTIME Number readOnly

UNIFORM_RANDOM01 Number readOnly

UNIFORM_SAMPLER Number readOnly

UNIFORM_MAX Number readOnly

SHADER_POSITION_TEXTURECOLOR String readOnly

SHADER_POSITION_TEXTURECOLORALPHATEST String readOnly

SHADER_POSITION_COLOR String readOnly

SHADER_POSITION_TEXTURE String readOnly

SHADER_POSITION_TEXTURE_UCOLOR String readOnly

SHADER_POSITION_TEXTUREA8COLOR String readOnly

SHADER_POSITION_UCOLOR String readOnly

SHADER_POSITION_LENGTHTEXTURECOLOR String readOnly

UNIFORM_PMATRIX_S String readOnly

UNIFORM_MVMATRIX_S String readOnly

UNIFORM_MVPMATRIX_S String readOnly

UNIFORM_TIME_S String readOnly

UNIFORM_SINTIME_S String readOnly

UNIFORM_COSTIME_S String readOnly

UNIFORM_RANDOM01_S String readOnly

UNIFORM_SAMPLER_S String readOnly

UNIFORM_ALPHA_TEST_VALUE_S String readOnly

ATTRIBUTE_NAME_COLOR String readOnly

ATTRIBUTE_NAME_POSITION String readOnly

ATTRIBUTE_NAME_TEX_COORD String readOnly

ITEM_SIZE Number readOnly

default size for font size

CURRENT_ITEM Number readOnly

default tag for current item

ZOOM_ACTION_TAG Number readOnly

default tag for zoom action tag

NORMAL_TAG Number readOnly

default tag for normal

SELECTED_TAG Number readOnly

default selected tag

DISABLE_TAG Number readOnly

default disabled tag

FIX_ARTIFACTS_BY_STRECHING_TEXEL Number readOnly

If enabled, the texture coordinates will be calculated by using this formula:
- texCoord.left = (rect.x2+1) / (texture.wide2);
- texCoord.right = texCoord.left + (rect.width2-2)/(texture.wide2);

The same for bottom and top.

This formula prevents artifacts by using 99% of the texture.
The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.

Affected nodes:
- _ccsg.Sprite / cc.SpriteBatchNode and subclasses: cc.LabelBMFont, _ccsg.TMXTiledMap
- cc.LabelAtlas
- cc.QuadParticleSystem
- cc.TileMap

To enabled set it to 1. Disabled by default.
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

DIRECTOR_STATS_POSITION Vec2 readOnly

Position of the FPS (Default: 0,0 (bottom-left corner))
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

DIRECTOR_FPS_INTERVAL Number readOnly

Seconds between FPS updates.
0.5 seconds, means that the FPS number will be updated every 0.5 seconds.
Having a bigger number means a more reliable FPS

Default value: 0.1f
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

COCOSNODE_RENDER_SUBPIXEL Number readOnly

If enabled, the ccsg.Node objects (_ccsg.Sprite, _ccsg.Label,etc) will be able to render in subpixels.
If disabled, integer pixels will be used.

To enable set it to 1. Enabled by default.
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

SPRITEBATCHNODE_RENDER_SUBPIXEL Number readOnly

If enabled, the _ccsg.Sprite objects rendered with cc.SpriteBatchNode will be able to render in subpixels.
If disabled, integer pixels will be used.

To enable set it to 1. Enabled by default.
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

AUTO_PREMULTIPLIED_ALPHA_FOR_PNG Number readOnly

Automatically premultiply alpha for PNG resources

OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA Number readOnly

If most of your images have pre-multiplied alpha, set it to 1 (if you are going to use .PNG/.JPG file images).
Only set to 0 if ALL your images by-pass Apple UIImage loading system (eg: if you use libpng or PVR images)

To enable set it to a value different than 0. Enabled by default.
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

TEXTURE_ATLAS_USE_TRIANGLE_STRIP Number readOnly

Use GL_TRIANGLE_STRIP instead of GL_TRIANGLES when rendering the texture atlas.
It seems it is the recommend way, but it is much slower, so, enable it at your own risk

To enable set it to a value different than 0. Disabled by default.
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

TEXTURE_ATLAS_USE_VAO Number readOnly

By default, cc.TextureAtlas (used by many cocos2d classes) will use VAO (Vertex Array Objects).
Apple recommends its usage but they might consume a lot of memory, specially if you use many of them.
So for certain cases, where you might need hundreds of VAO objects, it might be a good idea to disable it.

To disable it set it to 0. disable by default.(Not Supported on WebGL)
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

USE_LA88_LABELS Number readOnly

If enabled, it will use LA88 (Luminance Alpha 16-bit textures) for CCLabelTTF objects.
If it is disabled, it will use A8 (Alpha 8-bit textures).
LA88 textures are 6% faster than A8 textures, but they will consume 2x memory.

This feature is enabled by default.

SPRITE_DEBUG_DRAW Number readOnly

If enabled, all subclasses of _ccsg.Sprite will draw a bounding box
Useful for debugging purposes only. It is recommend to leave it disabled.

To enable set it to a value different than 0. Disabled by default:
0 -- disabled
1 -- draw bounding box
2 -- draw texture box

LABELBMFONT_DEBUG_DRAW Number readOnly

If enabled, all subclasses of cc.LabelBMFont will draw a bounding box
Useful for debugging purposes only. It is recommend to leave it disabled.

To enable set it to a value different than 0. Disabled by default.

LABELATLAS_DEBUG_DRAW Number readOnly

If enabled, all subclasses of cc.LabelAtlas will draw a bounding box
Useful for debugging purposes only. It is recommend to leave it disabled.

To enable set it to a value different than 0. Disabled by default.

ENABLE_STACKABLE_ACTIONS Number readOnly

If enabled, actions that alter the position property (eg: CCMoveBy, CCJumpBy, CCBezierBy, etc..) will be stacked.
If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions.
If disabled, only the last run action will take effect.

ENABLE_GL_STATE_CACHE Number readOnly

If enabled, cocos2d will maintain an OpenGL state cache internally to avoid unnecessary switches.
In order to use them, you have to use the following functions, instead of the the GL ones:
- cc.gl.useProgram() instead of glUseProgram()
- cc.gl.deleteProgram() instead of glDeleteProgram()
- cc.gl.blendFunc() instead of glBlendFunc()

If this functionality is disabled, then cc.gl.useProgram(), cc.gl.deleteProgram(), cc.gl.blendFunc() will call the GL ones, without using the cache.
It is recommend to enable whenever possible to improve speed.
If you are migrating your code from GL ES 1.1, then keep it disabled. Once all your code works as expected, turn it on.

BLEND_SRC Number readOnly

default gl blend src function. Compatible with premultiplied alpha images.

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