Cocos Creator API

1.5.x

Cocos Creator is the game engine for the future.

Enum macro

Module: _decorator
Parent Module: cc

Predefined constants

INVALID_INDEX Number

NODE_TAG_INVALID Number

Default Node tag

PI Number

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

PI2 Number

PI * 2

FLT_MAX Number

Maximum float value

FLT_MIN Number

Minimum float value

RAD Number

PI / 180

DEG Number

One degree

UINT_MAX Number

Maximum unsigned int value

REPEAT_FOREVER Number

FLT_EPSILON Number

ONE Number

ZERO Number

SRC_ALPHA Number

SRC_ALPHA_SATURATE Number

SRC_COLOR Number

DST_ALPHA Number

DST_COLOR Number

ONE_MINUS_SRC_ALPHA Number

ONE_MINUS_SRC_COLOR Number

ONE_MINUS_DST_ALPHA Number

ONE_MINUS_DST_COLOR Number

ONE_MINUS_CONSTANT_ALPHA Number

ONE_MINUS_CONSTANT_COLOR Number

LINEAR Number

the constant variable equals gl.LINEAR for texture

BLEND_DST Number

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

WEB_ORIENTATION_PORTRAIT Number

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

WEB_ORIENTATION_LANDSCAPE_LEFT Number

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

WEB_ORIENTATION_PORTRAIT_UPSIDE_DOWN Number

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

WEB_ORIENTATION_LANDSCAPE_RIGHT Number

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

ORIENTATION_PORTRAIT Number

Oriented vertically

ORIENTATION_LANDSCAPE Number

Oriented horizontally

ORIENTATION_AUTO Number

Oriented automatically

VERTEX_ATTRIB_FLAG_NONE Number

VERTEX_ATTRIB_FLAG_POSITION Number

VERTEX_ATTRIB_FLAG_COLOR Number

VERTEX_ATTRIB_FLAG_TEX_COORDS Number

VERTEX_ATTRIB_FLAG_POS_COLOR_TEX Number

GL_ALL Number

GL server side states

VERTEX_ATTRIB_POSITION Number

VERTEX_ATTRIB_COLOR Number

VERTEX_ATTRIB_TEX_COORDS Number

VERTEX_ATTRIB_MAX Number

UNIFORM_PMATRIX Number

UNIFORM_MVMATRIX Number

UNIFORM_MVPMATRIX Number

UNIFORM_TIME Number

UNIFORM_SINTIME Number

UNIFORM_COSTIME Number

UNIFORM_RANDOM01 Number

UNIFORM_SAMPLER Number

UNIFORM_MAX Number

SHADER_POSITION_TEXTURECOLOR String

SHADER_SPRITE_POSITION_TEXTURECOLOR String

SHADER_POSITION_TEXTURECOLORALPHATEST String

SHADER_SPRITE_POSITION_TEXTURECOLORALPHATEST String

SHADER_POSITION_COLOR String

SHADER_SPRITE_POSITION_COLOR String

SHADER_POSITION_TEXTURE String

SHADER_POSITION_TEXTURE_UCOLOR String

SHADER_POSITION_TEXTUREA8COLOR String

SHADER_POSITION_UCOLOR String

SHADER_POSITION_LENGTHTEXTURECOLOR String

UNIFORM_PMATRIX_S String

UNIFORM_MVMATRIX_S String

UNIFORM_MVPMATRIX_S String

UNIFORM_TIME_S String

UNIFORM_SINTIME_S String

UNIFORM_COSTIME_S String

UNIFORM_RANDOM01_S String

UNIFORM_SAMPLER_S String

UNIFORM_ALPHA_TEST_VALUE_S String

ATTRIBUTE_NAME_COLOR String

ATTRIBUTE_NAME_POSITION String

ATTRIBUTE_NAME_TEX_COORD String

ITEM_SIZE Number

default size for font size

CURRENT_ITEM Number

default tag for current item

ZOOM_ACTION_TAG Number

default tag for zoom action tag

NORMAL_TAG Number

default tag for normal

SELECTED_TAG Number

default selected tag

DISABLE_TAG Number

default disabled tag

FIX_ARTIFACTS_BY_STRECHING_TEXEL Number

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 expand the texture's border with the same color by 1 pixel

Affected nodes:
- _ccsg.Sprite
- _ccsg.TMXTiledMap

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

DIRECTOR_STATS_POSITION Vec2

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

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

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

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

Automatically premultiply alpha for PNG resources

OPTIMIZE_BLEND_FUNC_FOR_PREMULTIPLIED_ALPHA Number

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

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

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

TEXTURE_NPOT_SUPPORT Number deprecated

deprecated: This value will be removed in 1.1 and NPOT textures will be loaded by default if the device supports it.

If enabled, NPOT textures will be used where available. Only 3rd gen (and newer) devices support NPOT textures.
NPOT textures have the following limitations:
- They can't have mipmaps
- They only accept GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}

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

This value governs only the PNG, GIF, BMP, images.
This value DOES NOT govern the PVR (PVR.GZ, PVR.CCZ) files. If NPOT PVR is loaded, then it will create an NPOT texture ignoring this value.
To modify it, in Web engine please refer to CCMacro.js, in JSB please refer to CCConfig.h

USE_LA88_LABELS Number

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

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

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

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

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

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.

TOUCH_TIMEOUT Number

The timeout to determine whether a touch is no longer active and should be removed. The reason to add this timeout is due to an issue in X5 browser core, when X5 is presented in wechat on Android, if a touch is glissed from the bottom up, and leave the page area, no touch cancel event is triggered, and the touch will be considered active forever. After multiple times of this action, our maximum touches number will be reached and all new touches will be ignored. So this new mechanism can remove the touch that should be inactive if it's not updated during the last 5000 milliseconds. Though it might remove a real touch if it's just not moving for the last 5 seconds which is not easy with the sensibility of mobile touch screen. You can modify this value to have a better behavior if you find it's not enough.

BATCH_VERTEX_COUNT Number

The maximum vertex count for a single batched draw call.

ENABLE_GC_FOR_NATIVE_OBJECTS Number

JSB only, using JS object life cycle to control C++ object or inversely, it indicates two different memory model controled by the native macro CC_ENABLE_GC_FOR_NATIVE_OBJECTS. Modify the JS macro value won't have any effect.

ENABLE_TILEDMAP_CULLING Boolean

Whether or not enabled tiled map auto culling. If you use cc.Camera as tiled map's camera, please disable this macro.

DOWNLOAD_MAX_CONCURRENT Number

The max concurrent task number for the downloader

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