cc Module

The main namespace of Cocos2d-JS, all engine core classes, functions, properties and constants are defined in this namespace.

Classes

Enums

Index

Properties
  • ENGINE_VERSION String The current version of Cocos2d being used.
    Please DO NOT remove this String, it is an important flag for bug tracking.
    If you post a bug to forum, please attach this flag.
  • _renderContext CanvasRenderingContext2D|WebGLRenderingContext main Canvas 2D/3D Context of game engine
  • _canvas HTMLCanvasElement Main canvas of game engine
  • container HTMLDivElement The element contains the game canvas
  • view View cc.view is the shared view object.
  • director Director Director
  • winSize Size cc.winSize is the alias object for the size of the current game window.
  • game Game
  • systemEvent SystemEvent The System event singleton for global usage
  • Integer string Specify that the input value must be integer in Inspector. Also used to indicates that the elements in array should be type integer.
  • Float string Indicates that the elements in array should be type double.
  • Boolean string Indicates that the elements in array should be type boolean.
  • String string Indicates that the elements in array should be type string.
Methods

Details

Properties

ENGINE_VERSION

The current version of Cocos2d being used.
Please DO NOT remove this String, it is an important flag for bug tracking.
If you post a bug to forum, please attach this flag.

meta description
Type String
Defined in https:/github.com/cocos-creator/engine/blob/master/CCBoot.js:31
_renderContext

main Canvas 2D/3D Context of game engine

meta description
Type CanvasRenderingContext2D | WebGLRenderingContext
Defined in https:/github.com/cocos-creator/engine/blob/master/CCBoot.js:41
_canvas

Main canvas of game engine

meta description
Type HTMLCanvasElement
Defined in https:/github.com/cocos-creator/engine/blob/master/CCBoot.js:48
container

The element contains the game canvas

meta description
Type HTMLDivElement
Defined in https:/github.com/cocos-creator/engine/blob/master/CCBoot.js:54
view

cc.view is the shared view object.

meta description
Type View
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCGame.js:377
director

Director

meta description
Type Director
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCGame.js:385
winSize

cc.winSize is the alias object for the size of the current game window.

meta description
Type Size
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCGame.js:394
game
meta description
Type Game
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/CCGame.js:829
systemEvent

The System event singleton for global usage

meta description
Type SystemEvent
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/event/system-event.js:194
Integer

Specify that the input value must be integer in Inspector. Also used to indicates that the elements in array should be type integer.

meta description
Type string
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/attribute.js:152
Examples
// in cc.Class
member: {
    default: [],
    type: cc.Integer
}
// ES6 ccclass
Float

Indicates that the elements in array should be type double.

meta description
Type string
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/attribute.js:171
Examples
// in cc.Class
member: {
    default: [],
    type: cc.Float
}
// ES6 ccclass
Boolean

Indicates that the elements in array should be type boolean.

meta description
Type string
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/attribute.js:196
Examples
// in cc.Class
member: {
    default: [],
    type: cc.Boolean
}
// ES6 ccclass
String

Indicates that the elements in array should be type string.

meta description
Type string
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/attribute.js:214
Examples
// in cc.Class
member: {
    default: [],
    type: cc.String
}
// ES6 ccclass

Methods

_initDebugSetting

Init Debug setting.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/CCDebugger.js:102
Parameters
error

Outputs an error message to the Cocos Creator Console (editor) or Web Console (runtime).

  • In Cocos Creator, error is red.
  • In Chrome, error have a red icon along with red message text.
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/CCDebugger.js:180
Parameters
  • msg Any A JavaScript string containing zero or more substitution strings.
  • subst Any JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
warn

Outputs a warning message to the Cocos Creator Console (editor) or Web Console (runtime).

  • In Cocos Creator, warning is yellow.
  • In Chrome, warning have a yellow warning icon with the message text.
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/CCDebugger.js:224
Parameters
  • msg Any A JavaScript string containing zero or more substitution strings.
  • subst Any JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
log

Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/CCDebugger.js:255
Parameters
  • msg String | Any A JavaScript string containing zero or more substitution strings.
  • subst Any JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
info

Outputs an informational message to the Cocos Creator Console (editor) or Web Console (runtime).

  • In Cocos Creator, info is blue.
  • In Firefox and Chrome, a small "i" icon is displayed next to these items in the Web Console's log.
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/CCDebugger.js:281
Parameters
  • msg Any A JavaScript string containing zero or more substitution strings.
  • subst Any JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
speed

Creates the speed action which changes the speed of an action, making it take longer (speed > 1) or less (speed < 1) time.
Useful to simulate 'slow motion' or 'fast forward' effect.

meta description
Returns Action
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCAction.js:366
Parameters
Examples
// change the target action speed;
var action = cc.scaleTo(0.2, 1, 0.6);
var newAction = cc.speed(action, 0.5);
follow

Create a follow action which makes its target follows another node.

meta description
Returns Action | Null
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCAction.js:561
Parameters
Examples
// example
// creates the action with a set boundary
var followAction = cc.follow(targetNode, cc.rect(0, 0, screenWidth * 2 - 100, screenHeight));
node.runAction(followAction);

// creates the action with no boundary set
var followAction = cc.follow(targetNode);
node.runAction(followAction);
setPoints

Points setter

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionCatmullRom.js:224
Parameters
cardinalSplineTo

Creates an action with a Cardinal Spline array of points and tension.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionCatmullRom.js:234
Parameters
Examples
//create a cc.CardinalSplineTo
var action1 = cc.cardinalSplineTo(3, array, 0);
updatePosition

update position of target

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionCatmullRom.js:318
Parameters
cardinalSplineBy

Creates an action with a Cardinal Spline array of points and tension.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionCatmullRom.js:339
Parameters
catmullRomTo

Creates an action with a Cardinal Spline array of points and tension.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionCatmullRom.js:385
Parameters
Examples
var action1 = cc.catmullRomTo(3, array);
catmullRomBy

Creates an action with a Cardinal Spline array of points and tension.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionCatmullRom.js:433
Parameters
Examples
var action1 = cc.catmullRomBy(3, array);
easeIn

Creates the action easing object with the rate parameter.
From slow to fast.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:197
Parameters
Examples
action.easing(cc.easeIn(3.0));
easeOut

Creates the action easing object with the rate parameter.
From fast to slow.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:247
Parameters
Examples
action.easing(cc.easeOut(3.0));
easeInOut

Creates the action easing object with the rate parameter.
Slow to fast then to slow.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:301
Parameters
Examples
action.easing(cc.easeInOut(3.0));
easeExponentialIn

Creates the action easing object with the rate parameter.
Reference easeInExpo:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:366
Examples
action.easing(cc.easeExponentialIn());
easeExponentialOut

Creates the action easing object.
Reference easeOutExpo:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:421
Examples
action.easing(cc.easeExponentialOut());
easeExponentialInOut

Creates an EaseExponentialInOut action easing object.
Reference easeInOutExpo:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:491
Examples
action.easing(cc.easeExponentialInOut());
easeSineIn

Creates an EaseSineIn action.
Reference easeInSine:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:546
Examples
action.easing(cc.easeSineIn());
easeSineOut

Creates an EaseSineOut action easing object.
Reference easeOutSine:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:602
Examples
action.easing(cc.easeSineOut());
easeSineInOut

Creates the action easing object.
Reference easeInOutSine:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:658
Examples
action.easing(cc.easeSineInOut());
easeElasticIn

Creates the action easing obejct with the period in radians (default is 0.3).
Reference easeInElastic:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:787
Parameters
Examples
// example
action.easing(cc.easeElasticIn(3.0));
easeElasticOut

Creates the action easing object with the period in radians (default is 0.3).
Reference easeOutElastic:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:867
Parameters
Examples
// example
action.easing(cc.easeElasticOut(3.0));
easeElasticInOut

Creates the action easing object with the period in radians (default is 0.3).
Reference easeInOutElastic:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:943
Parameters
Examples
// example
action.easing(cc.easeElasticInOut(3.0));
easeBounceIn

Creates the action easing object.
Eased bounce effect at the beginning.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1081
Examples
// example
action.easing(cc.easeBounceIn());
easeBounceOut

Creates the action easing object.
Eased bounce effect at the ending.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1136
Examples
// example
action.easing(cc.easeBounceOut());
easeBounceInOut

Creates the action easing object.
Eased bounce effect at the begining and ending.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1204
Examples
// example
action.easing(cc.easeBounceInOut());
easeBackIn

Creates the action easing object.
In the opposite direction to move slowly, and then accelerated to the right direction.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1261
Examples
// example
action.easing(cc.easeBackIn());
easeBackOut

Creates the action easing object.
Fast moving more than the finish, and then slowly back to the finish.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1319
Examples
// example
action.easing(cc.easeBackOut());
easeBackInOut

Creates the action easing object.
Begining of cc.EaseBackIn. Ending of cc.EaseBackOut.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1387
Examples
// example
action.easing(cc.easeBackInOut());
easeBezierAction

Creates the action easing object.
Into the 4 reference point.
To calculate the motion curve.

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1469
Parameters
  • p0 Number The first bezier parameter
  • p1 Number The second bezier parameter
  • p2 Number The third bezier parameter
  • p3 Number The fourth bezier parameter
Examples
// example
action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));
easeQuadraticActionIn

Creates the action easing object.
Reference easeInQuad:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1539
Examples
//example
action.easing(cc.easeQuadraticActionIn());
easeQuadraticActionOut

Creates the action easing object.
Reference easeOutQuad:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1597
Examples
//example
action.easing(cc.easeQuadraticActionOut());
easeQuadraticActionInOut

Creates the action easing object.
Reference easeInOutQuad:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1663
Examples
//example
action.easing(cc.easeQuadraticActionInOut());
easeQuarticActionIn

Creates the action easing object.
Reference easeIntQuart:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1720
Examples
//example
action.easing(cc.easeQuarticActionIn());
easeQuarticActionOut

Creates the action easing object.
Reference easeOutQuart:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1779
Examples
//example
action.easing(cc.QuarticActionOut());
easeQuarticActionInOut

Creates the action easing object.
Reference easeInOutQuart:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1840
easeQuinticActionIn

Creates the action easing object.
Reference easeInQuint:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1895
Examples
//example
action.easing(cc.easeQuinticActionIn());
easeQuinticActionOut

Creates the action easing object.
Reference easeOutQuint:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:1954
Examples
//example
action.easing(cc.easeQuadraticActionOut());
easeQuinticActionInOut

Creates the action easing object.
Reference easeInOutQuint:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:2016
Examples
//example
action.easing(cc.easeQuinticActionInOut());
easeCircleActionIn

Creates the action easing object.
Reference easeInCirc:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:2074
Examples
//example
action.easing(cc.easeCircleActionIn());
easeCircleActionOut

Creates the action easing object.
Reference easeOutCirc:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:2133
easeCircleActionInOut

Creates the action easing object.
Reference easeInOutCirc:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:2195
Examples
//example
action.easing(cc.easeCircleActionInOut());
easeCubicActionIn

Creates the action easing object.
Reference easeInCubic:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:2253
Examples
//example
action.easing(cc.easeCubicActionIn());
easeCubicActionOut

Creates the action easing object.
Reference easeOutCubic:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:2312
Examples
//example
action.easing(cc.easeCubicActionOut());
easeCubicActionInOut

Creates the action easing object.
Reference easeInOutCubic:
http://www.zhihu.com/question/21981571/answer/19925418

meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionEase.js:2374
show

Show the Node.

meta description
Returns ActionInstant
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInstant.js:97
Examples
// example
var showAction = cc.show();
hide

Hide the node.

meta description
Returns ActionInstant
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInstant.js:134
Examples
// example
var hideAction = cc.hide();
toggleVisibility

Toggles the visibility of a node.

meta description
Returns ActionInstant
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInstant.js:171
Examples
// example
var toggleVisibilityAction = cc.toggleVisibility();
removeSelf

Create a RemoveSelf object with a flag indicate whether the target should be cleaned up while removing.

meta description
Returns ActionInstant
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInstant.js:221
Parameters
Examples
// example
var removeSelfAction = cc.removeSelf();
flipX

Create a FlipX action to flip or unflip the target.

meta description
Returns ActionInstant
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInstant.js:279
Parameters
  • flip Boolean Indicate whether the target should be flipped or not
Examples
var flipXAction = cc.flipX(true);
flipY

Create a FlipY action to flip or unflip the target.

meta description
Returns ActionInstant
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInstant.js:335
Parameters
Examples
var flipYAction = cc.flipY(true);
place

Creates a Place action with a position.

meta description
Returns ActionInstant
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInstant.js:399
Parameters
Examples
// example
var placeAction = cc.place(cc.p(200, 200));
var placeAction = cc.place(200, 200);
callFunc

Creates the action with the callback.

meta description
Returns ActionInstant
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInstant.js:509
Parameters
  • selector function
  • selectorTarget object
  • data Any data for function, it accepts all data types.
Examples
// example
// CallFunc without data
var finish = cc.callFunc(this.removeSprite, this);

// CallFunc with data
var finish = cc.callFunc(this.removeFromParentAndCleanup, this._grossini,  true);
sequence

Helper constructor to create an array of sequenceable actions The created action will run actions sequentially, one after another.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:435
Parameters
Examples
// example
// create sequence with actions
var seq = cc.sequence(act1, act2);

// create sequence with array
var seq = cc.sequence(actArray);
repeat

Creates a Repeat action. Times is an unsigned integer between 1 and pow(2,30)

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:613
Parameters
Examples
// example
var rep = cc.repeat(cc.sequence(jump2, jump1), 5);
repeatForever

Create a acton which repeat forever, as it runs forever, it can't be added into cc.sequence and cc.spawn.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:716
Parameters
Examples
// example
var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));
spawn

Create a spawn action which runs several actions in parallel.

meta description
Returns FiniteTimeAction
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:830
Parameters
Examples
// example
var action = cc.spawn(cc.jumpBy(2, cc.p(300, 0), 50, 4), cc.rotateBy(2, 720));
todo:It should be the direct use new
rotateTo

Rotates a Node object to a certain angle by modifying its rotation property.
The direction will be decided by the shortest angle.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:951
Parameters
  • duration Number duration in seconds
  • deltaAngleX Number deltaAngleX in degrees.
  • deltaAngleY Number deltaAngleY in degrees.
Examples
// example
var rotateTo = cc.rotateTo(2, 61.0);
rotateBy

Rotates a Node object clockwise a number of degrees by modifying its rotation property. Relative to its properties to modify.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1038
Parameters
  • duration Number duration in seconds
  • deltaAngleX Number deltaAngleX in degrees
  • deltaAngleY Number deltaAngleY in degrees
Examples
// example
var actionBy = cc.rotateBy(2, 360);
moveBy

Moves a Node object x,y pixels by modifying its position property.
x and y are relative to the position of the object.
Several MoveBy actions can be concurrently called, and the resulting
movement will be the sum of individual movements.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1157
Parameters
Examples
// example
var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));
moveTo

Moves a Node object to the position x,y. x and y are absolute coordinates by modifying its position property.
Several MoveTo actions can be concurrently called, and the resulting
movement will be the sum of individual movements.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1235
Parameters
Examples
// example
var actionBy = cc.moveTo(2, cc.p(80, 80));
skewTo

Create a action which skews a Node object to given angles by modifying its skewX and skewY properties. Changes to the specified value.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1329
Parameters
Examples
// example
var actionTo = cc.skewTo(2, 37.2, -37.2);
skewBy

Skews a Node object by skewX and skewY degrees.
Relative to its property modification.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1403
Parameters
  • t Number time in seconds
  • sx Number sx skew in degrees for X axis
  • sy Number sy skew in degrees for Y axis
Examples
// example
var actionBy = cc.skewBy(2, 0, -90);
jumpBy

Moves a Node object simulating a parabolic jump movement by modifying it's position property. Relative to its movement.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1532
Parameters
Examples
// example
var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4);
var actionBy = cc.jumpBy(2, 300, 0, 50, 4);
jumpTo

Moves a Node object to a parabolic position simulating a jump movement by modifying its position property.
Jump to the specified location.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1615
Parameters
Examples
// example
var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4);
var actionTo = cc.jumpTo(2, 300, 300, 50, 4);
bezierBy

An action that moves the target with a cubic Bezier curve by a certain distance. Relative to its movement.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1761
Parameters
Examples
// example
var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
var bezierForward = cc.bezierBy(3, bezier);
bezierTo

An action that moves the target with a cubic Bezier curve to a destination point.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1830
Parameters
Examples
// example
var bezier = [cc.p(0, windowSize.height / 2), cc.p(300, -windowSize.height / 2), cc.p(300, 100)];
var bezierTo = cc.bezierTo(2, bezier);
scaleTo

Scales a Node object to a zoom factor by modifying it's scale property.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1915
Parameters
  • duration Number
  • sx Number scale parameter in X
  • sy Number scale parameter in Y, if Null equal to sx
Examples
// example
// It scales to 0.5 in both X and Y.
var actionTo = cc.scaleTo(2, 0.5);

// It scales to 0.5 in x and 2 in Y
var actionTo = cc.scaleTo(2, 0.5, 2);
scaleBy

Scales a Node object a zoom factor by modifying it's scale property. Relative to its changes.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:1962
Parameters
  • duration Number duration in seconds
  • sx Number sx scale parameter in X
  • sy Number | Null sy scale parameter in Y, if Null equal to sx
Examples
// example without sy, it scales by 2 both in X and Y
var actionBy = cc.scaleBy(2, 2);

//example with sy, it scales by 0.25 in X and 4.5 in Y
var actionBy2 = cc.scaleBy(2, 0.25, 4.5);

Blinks a Node object by modifying it's visible property.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:2047
Parameters
  • duration Number duration in seconds
  • blinks Number blinks in times
Examples
// example
var action = cc.blink(2, 10);
fadeTo

Fades an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from the current value to a custom one.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:2113
Parameters
Examples
// example
var action = cc.fadeTo(1.0, 0);
fadeIn

Fades In an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 0 to 255.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:2168
Parameters
  • duration Number duration in seconds
Examples
//example
var action = cc.fadeIn(1.0);
fadeOut

Fades Out an object that implements the cc.RGBAProtocol protocol. It modifies the opacity from 255 to 0.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:2215
Parameters
  • d Number duration in seconds
Examples
// example
var action = cc.fadeOut(1.0);
tintTo

Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:2302
Parameters
Examples
// example
var action = cc.tintTo(2, 255, 0, 255);
tintBy

Tints a Node that implements the cc.NodeRGB protocol from current tint to a custom one. Relative to their own color change.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:2395
Parameters
Examples
// example
var action = cc.tintBy(2, -127, -255, -127);
delayTime

Delays the action a certain amount of seconds. 延迟指定的时间量。

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:2436
Parameters
  • d Number duration in seconds
Examples
// example
var delay = cc.delayTime(1);
reverseTime

Executes an action in reverse order, from time=duration to time=0.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:2519
Parameters
Examples
// example
 var reverse = cc.reverseTime(this);
targetedAction

Create an action with the specified action and forced target.

meta description
Returns ActionInterval
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/actions/CCActionInterval.js:2776
Parameters
handleTouchesBegin
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:90
Parameters
handleTouchesMove
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:125
Parameters
handleTouchesEnd
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:157
Parameters
handleTouchesCancel
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:171
Parameters
getSetOfTouchesEndOrCancel
meta description
Returns Array
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:185
Parameters
getHTMLElementPosition
meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:212
Parameters
getPreTouch
meta description
Returns Touch
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:250
Parameters
setPreTouch
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:270
Parameters
getTouchByXY
meta description
Returns Touch
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:296
Parameters
getPointByEvent
meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:313
Parameters
getTouchesByEvent
meta description
Returns Array
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:335
Parameters
registerSystemEvent
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/BKInputManager.js:411
Parameters
Class

Defines a CCClass using the given specification, please see Class for details.

meta description
Returns Function
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCClass.js:828
Parameters
  • options Object
    • name String The class name used for serialization.
    • extends Function The base class.
    • ctor Function The constructor.
    • __ctor__ Function The same as ctor, but less encapsulated.
    • properties Object The property definitions.
    • statics Object The static members.
    • mixins Function[]
    • editor Object attributes for Component listed below.
      • executeInEditMode Boolean Allows the current component to run in edit mode. By default, all components are executed only at runtime, meaning that they will not have their callback functions executed while the Editor is in edit mode.
      • requireComponent Function Automatically add required component as a dependency.
      • menu String The menu path to register a component to the editors "Component" menu. Eg. "Rendering/Camera".
      • executionOrder Number The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after. The order will only affect onLoad, onEnable, start, update and lateUpdate while onDisable and onDestroy will not be affected.
      • disallowMultiple Boolean If specified to a type, prevents Component of the same type (or subtype) to be added more than once to a Node.
      • playOnFocus Boolean This property is only available when executeInEditMode is set. If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
      • inspector String Customize the page url used by the current component to render in the Properties.
      • icon String Customize the icon that the current component displays in the editor.
      • help String The custom documentation URL
    • update Function lifecycle method for Component, see update
    • lateUpdate Function lifecycle method for Component, see lateUpdate
    • onLoad Function lifecycle method for Component, see onLoad
    • start Function lifecycle method for Component, see start
    • onEnable Function lifecycle method for Component, see onEnable
    • onDisable Function lifecycle method for Component, see onDisable
    • onDestroy Function lifecycle method for Component, see onDestroy
    • onFocusInEditor Function lifecycle method for Component, see onFocusInEditor
    • onLostFocusInEditor Function lifecycle method for Component, see onLostFocusInEditor
    • resetInEditor Function lifecycle method for Component, see resetInEditor
    • onRestore Function for Component only, see onRestore
    • _getLocalBounds Function for Component only, see _getLocalBounds
Examples
// define base class
var Node = cc.Class();

// define sub class
var Sprite = cc.Class({
name: 'Sprite',
extends: Node,
ctor: function () {
this.url = "";
this.id = 0;
},

statics: {
// define static members
count: 0,
getBounds: function (spriteList) {
// compute bounds...
}
},

properties {
width: {
default: 128,
type: 'Integer',
tooltip: 'The width of sprite'
},
height: 128,
size: {
get: function () {
return cc.v2(this.width, this.height);
}
}
},

load: function () {
// load this.url...
};
});

// instantiate

var obj = new Sprite();
obj.url = 'sprite.png';
obj.load();
_isCCClass

Checks whether the constructor is created by cc.Class

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCClass.js:992
Parameters
isChildClassOf

Checks whether subclass is child of superclass or equals to superclass

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCClass.js:1029
Parameters
getInheritanceChain

Return all super classes

meta description
Returns Function[]
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCClass.js:1064
Parameters
Enum

Define an enum type.
If a enum item has a value of -1, it will be given an Integer number according to it's order in the list.
Otherwise it will use the value specified by user who writes the enum definition.

meta description
Returns object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCEnum.js:33
Parameters
  • obj object a JavaScript literal object containing enum names and values, or a TypeScript enum type
Examples
// JavaScript:

var WrapMode = cc.Enum({
    Repeat: -1,
    Clamp: -1
});

// Texture.WrapMode.Repeat == 0
// Texture.WrapMode.Clamp == 1
// Texture.WrapMode[0] == "Repeat"
// Texture.WrapMode[1] == "Clamp"

var FlagType = cc.Enum({
    Flag1: 1,
    Flag2: 2,
    Flag3: 4,
    Flag4: 8,
});

var AtlasSizeList = cc.Enum({
    128: 128,
    256: 256,
    512: 512,
    1024: 1024,
});

// TypeScript:

// If used in TypeScript, just define a TypeScript enum:
enum Direction {
    Up,
    Down,
    Left,
    Right
}

// If you need to inspect the enum in Properties panel, you can call cc.Enum:
const {ccclass, property} = cc._decorator;

@ccclass
class NewScript extends cc.Component {
    @property({
        default: Direction.Up,
        type: cc.Enum(Direction)    // call cc.Enum
    })
    direction: Direction = Direction.Up;
}
getList
meta description
Returns Object[]
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCEnum.js:89
Parameters
  • enumDef Object the enum type defined from cc.Enum
setAccelerometerEnabled

whether enable accelerometer event

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputExtension.js:38
Parameters
setAccelerometerInterval

set accelerometer interval value

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputExtension.js:59
Parameters
handleTouchesBegin
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:98
Parameters
handleTouchesMove
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:133
Parameters
handleTouchesEnd
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:165
Parameters
handleTouchesCancel
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:179
Parameters
getSetOfTouchesEndOrCancel
meta description
Returns Array
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:193
Parameters
getHTMLElementPosition
meta description
Returns Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:219
Parameters
getPreTouch
meta description
Returns Touch
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:266
Parameters
setPreTouch
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:286
Parameters
getTouchByXY
meta description
Returns Touch
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:311
Parameters
getTouchByXY
meta description
Returns Event.EventMouse
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:328
Parameters
getPointByEvent
meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:346
Parameters
getTouchesByEvent
meta description
Returns Array
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:367
Parameters
registerSystemEvent
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:405
Parameters
update
meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCInputManager.js:575
Parameters
lerp

Linear interpolation between 2 numbers, the ratio sets how much it is biased to each end

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCMacro.js:1979
Parameters
Examples
----
lerp
cc.lerp(2,10,0.5)//returns 6
cc.lerp(2,10,0.2)//returns 3.6
rand

get a random number from 0 to 0xffffff

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCMacro.js:1993
randomMinus1To1

returns a random float between -1 and 1

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCMacro.js:2002
random0To1

returns a random float between 0 and 1, use Math.random directly

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCMacro.js:2011
degreesToRadians

converts degrees to radians

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCMacro.js:2018
Parameters
radiansToDegrees

converts radians to degrees

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCMacro.js:2028
Parameters
nodeDrawSetup

Helpful macro that setups the GL server state, the correct GL program and sets the Model View Projection matrix

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCMacro.js:2038
Parameters
  • node Node setup node
incrementGLDraws

Increments the GL Draws counts by one.
The number of calls per frame are displayed on the screen when the CCDirector's stats are enabled.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCMacro.js:2090
Parameters
checkGLErrorDebug

Check webgl error.Error will be shown in console if exists.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCMacro.js:2102
isValid

Checks whether the object is non-nil and not yet destroyed.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/CCObject.js:460
Parameters
  • value Any
Examples
cc.log(cc.isValid(target));
deserialize

Deserialize json to cc.Asset

meta description
Returns object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/deserialize.js:821
Parameters
  • data String | Object the serialized cc.Asset json string or json object.
  • details Details additional loading result
  • options Object
instantiate

Clones the object original and returns the clone, or instantiate a node from the Prefab.

meta description
Returns Node | Object
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/platform/instantiate.js:35
Parameters
  • original Prefab | Node | Object An existing object that you want to make a copy of.
Examples
// instantiate node from prefab
var scene = cc.director.getScene();
var node = cc.instantiate(prefabAsset);
node.parent = scene;
// clone node
var scene = cc.director.getScene();
var node = cc.instantiate(targetNode);
node.parent = scene;
find

Finds a node by hierarchy path, the path is case-sensitive. It will traverse the hierarchy by splitting the path using '/' character. This function will still returns the node even if it is inactive. It is recommended to not use this function every frame instead cache the result at startup.

meta description
Returns Node | Null
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/utils/find.js:29
Parameters
color

The convenience method to create a new Color/Color:method Alpha channel is optional. Default value is 255.

meta description
Returns Color
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCColor.js:620
Parameters
Examples
-----------------------
// 1. All channels seperately as parameters
var color1 = new cc.Color(255, 255, 255, 255);
// 2. Convert a hex string to a color
var color2 = new cc.Color("#000000");
// 3. An color object as parameter
var color3 = new cc.Color({r: 255, g: 255, b: 255, a: 255});
colorEqual

returns true if both ccColor3B are equal. Otherwise it returns false.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCColor.js:651
Parameters
Examples
cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true
hexToColor

convert a string of color for style to Color. e.g. "#ff06ff" to : cc.color(255,6,255)。

meta description
Returns Color
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCColor.js:670
Parameters
Examples
cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};
colorToHex

convert Color to a string of color for style. e.g. cc.color(255,6,255) to : "#ff06ff"

meta description
Returns String
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCColor.js:690
Parameters
Examples
var color = new cc.Color(255, 6, 255)
cc.colorToHex(color); // #ff06ff;
pNeg

Returns opposite of Vec2.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:46
Parameters
Examples
cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10};
pAdd

Calculates sum of two points.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:59
Parameters
Examples
cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3};
pSub

Calculates difference of two points.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:73
Parameters
Examples
cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15};
pMult

Returns point multiplied by given factor.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:87
Parameters
Examples
cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20};
pMidpoint

Calculates midpoint between two points.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:101
Parameters
Examples
cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5};
pDot

Calculates dot product of two points.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:115
Parameters
Examples
cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200;
pCross

Calculates cross product of two points.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:129
Parameters
Examples
cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0;
pPerp

Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) greater than 0.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:143
Parameters
Examples
cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20};
pRPerp

Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) smaller than 0.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:156
Parameters
Examples
cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20};
pProject

Calculates the projection of v1 over v2.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:169
Parameters
Examples
var v1 = cc.v2(20, 20);
var v2 = cc.v2(5, 5);
cc.pProject(v1, v2); // Vec2 {x: 20, y: 20};
pLengthSQ

Calculates the square length of a cc.Vec2 (not calling sqrt() ).

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:185
Parameters
Examples
cc.pLengthSQ(cc.v2(20, 20)); // 800;
pDistanceSQ

Calculates the square distance between two points (not calling sqrt() ).

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:198
Parameters
Examples
var point1 = cc.v2(20, 20);
var point2 = cc.v2(5, 5);
cc.pDistanceSQ(point1, point2); // 450;
pLength

Calculates distance between point an origin.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:214
Parameters
Examples
cc.pLength(cc.v2(20, 20)); // 28.284271247461902;
pDistance

Calculates the distance between two points.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:227
Parameters
Examples
var v1 = cc.v2(20, 20);
var v2 = cc.v2(5, 5);
cc.pDistance(v1, v2); // 21.213203435596427;
pNormalize

Returns this vector with a magnitude of 1.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:243
Parameters
Examples
cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
pForAngle

Converts radians to a normalized vector.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:257
Parameters
Examples
cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277};
pToAngle

Converts a vector to radians.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:270
Parameters
Examples
cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483;
clampf

Clamp a value between from and to.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:283
Parameters
Examples
var v1 = cc.clampf(20, 0, 20); // 20;
var v2 = cc.clampf(-1, 0, 20); //  0;
var v3 = cc.clampf(10, 0, 20); // 10;
clamp01

Clamp a value between 0 and 1.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:309
Parameters
Examples
var v1 = cc.clampf(20);  // 1;
var v2 = cc.clampf(-1);  // 0;
var v3 = cc.clampf(0.5); // 0.5;
pClamp

Clamp a point between from and to.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:324
Parameters
Examples
var min_inclusive = cc.v2(0, 0);
var max_inclusive = cc.v2(20, 20);
var v1 = cc.pClamp(cc.v2(20, 20), min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
var v2 = cc.pClamp(cc.v2(0, 0), min_inclusive, max_inclusive);   // Vec2 {x: 0, y: 0};
var v3 = cc.pClamp(cc.v2(10, 10), min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
pFromSize

Quickly convert cc.Size to a cc.Vec2.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:347
Parameters
Examples
cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20};
pCompOp

Run a math operation function on each point component
Math.abs, Math.fllor, Math.ceil, Math.round.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:360
Parameters
Examples
cc.pCompOp(cc.p(-10, -10), Math.abs); // Vec2 {x: 10, y: 10};
pLerp

Linear Interpolation between two points a and b.
alpha == 0 ? a
alpha == 1 ? b
otherwise a value between a..b.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:376
Parameters
Examples
cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5};
pFuzzyEqual

TODO

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:399
Parameters
Examples
var a = cc.v2(20, 20);
var b = cc.v2(5, 5);
var b1 = cc.pFuzzyEqual(a, b, 10); // false;
var b2 = cc.pFuzzyEqual(a, b, 18); // true;
pCompMult

Multiplies a nd b components, a.xb.x, a.yb.y.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:423
Parameters
Examples
cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100};
pAngleSigned

TODO

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:437
Parameters
pAngle

TODO

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:454
Parameters
pRotateByAngle

Rotates a point counter clockwise by the angle around a pivot.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:468
Parameters
  • v Vec2 v is the point to rotate
  • pivot Vec2 pivot is the pivot, naturally
  • angle Number angle is the angle of rotation cw in radians
pLineIntersect

A general line-line intersection test indicating successful intersection of a line
note that to truly test intersection for segments we have to make
sure that s & t lie within [0..1] and for rays, make sure s & t > 0
the hit point is p3 + t (p4 - p3);
the hit point also is p1 + s
(p2 - p1);

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:486
Parameters
  • A Vec2 A is the startpoint for the first line P1 = (p1 - p2).
  • B Vec2 B is the endpoint for the first line P1 = (p1 - p2).
  • C Vec2 C is the startpoint for the second line P2 = (p3 - p4).
  • D Vec2 D is the endpoint for the second line P2 = (p3 - p4).
  • retP Vec2 retP.x is the range for a hitpoint in P1 (pa = p1 + s(p2 - p1)),
    retP.y is the range for a hitpoint in P3 (pa = p2 + t
    (p4 - p3)).
pSegmentIntersect

ccpSegmentIntersect return YES if Segment A-B intersects with segment C-D.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:537
Parameters
pIntersectPoint

ccpIntersectPoint return the intersection point of line A-B, C-D.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:555
Parameters
pSameAs

check to see if both points are equal.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:579
Parameters
  • A Vec2 A ccp a
  • B Vec2 B ccp b to be compared
pZeroIn

sets the position of the point to 0.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:598
Parameters
pIn

copies the position of one point to another.

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:609
Parameters
pMultIn

multiplies the point with the given factor (inplace).

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:621
Parameters
pSubIn

subtracts one point from another (inplace).

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:633
Parameters
pAddIn

adds one point to another (inplace).

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:645
Parameters
pNormalizeIn

normalizes the point (inplace).

meta description
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCPointExtension.js:657
Parameters
rect

The convenience method to create a new Rect. see Rect/Rect:method

meta description
Returns Rect
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:369
Parameters
Examples
var a = new cc.Rect(0 , 0, 10, 0);
rectEqualToRect

Check whether a rect's value equals to another.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:391
Parameters
Examples
var a = new cc.Rect(0, 0, 10, 10);
var b = new cc.Rect(0, 0, 5, 5);
cc.rectEqualToRect(a, b); // false;
var c = new cc.Rect(0, 0, 5, 5);
cc.rectEqualToRect(b, c); // true;
rectContainsRect

Check whether the rect1 contains rect2.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:413
Parameters
Examples
var a = new cc.Rect(0, 0, 20, 20);
var b = new cc.Rect(10, 10, 20, 20);
cc.rectContainsRect(a, b); // true;
rectGetMaxX

Returns the rightmost x-value of a rect.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:435
Parameters
Examples
var a = new cc.Rect(10, 0, 20, 20);
cc.rectGetMaxX(a); // 30;
rectGetMidX

Return the midpoint x-value of a rect.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:449
Parameters
Examples
var a = new cc.Rect(10, 0, 20, 20);
cc.rectGetMidX(a); // 20;
rectGetMinX

Returns the leftmost x-value of a rect.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:462
Parameters
Examples
var a = new cc.Rect(10, 0, 20, 20);
cc.rectGetMinX(a); // 10;
rectGetMaxY

Return the topmost y-value of a rect.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:476
Parameters
Examples
var a = new cc.Rect(0, 10, 20, 20);
cc.rectGetMaxY(a); // 30;
rectGetMidY

Return the midpoint y-value of `rect'.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:490
Parameters
Examples
var a = new cc.Rect(0, 10, 20, 20);
cc.rectGetMidY(a); // 20;
rectGetMinY

Return the bottommost y-value of a rect.

meta description
Returns Number
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:504
Parameters
Examples
var a = new cc.Rect(0, 10, 20, 20);
cc.rectGetMinY(a); // 10;
rectContainsPoint

Check whether a rect contains a point.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:518
Parameters
Examples
var a = new cc.Rect(0, 10, 20, 20);
var b = new cc.Vec2(0, 10, 10, 10);
cc.rectContainsPoint(a, b); // true;
rectIntersectsRect

Check whether a rect intersect with another.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:535
Parameters
Examples
var a = new cc.Rect(0, 10, 20, 20);
var b = new cc.Rect(0, 10, 10, 10);
cc.rectIntersectsRect(a, b); // true;
rectOverlapsRect

Check whether a rect overlaps another.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:555
Parameters
Examples
var a = new cc.Rect(0, 10, 20, 20);
var b = new cc.Rect(0, 10, 10, 10);
cc.rectOverlapsRect(a, b); // true;
rectUnion

Returns the smallest rectangle that contains the two source rectangles.

meta description
Returns Rect
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:574
Parameters
Examples
var a = new cc.Rect(0, 10, 20, 20);
var b = new cc.Rect(0, 10, 10, 10);
cc.rectUnion(a, b); // Rect {x: 0, y: 10, width: 20, height: 20};
rectIntersection

Returns the overlapping portion of 2 rectangles.

meta description
Returns Rect
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCRect.js:595
Parameters
Examples
var a = new cc.Rect(0, 10, 20, 20);
var b = new cc.Rect(0, 10, 10, 10);
cc.rectIntersection(a, b); // Rect {x: 0, y: 10, width: 10, height: 10};
size

Helper function that creates a cc.Size.
Please use cc.p or cc.v2 instead, it will soon replace cc.Size.

meta description
Returns Size
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCSize.js:157
Parameters
Examples
var size1 = cc.size();
var size2 = cc.size(100,100);
var size3 = cc.size(size2);
var size4 = cc.size({width: 100, height: 100});
sizeEqualToSize

Check whether a point's value equals to another.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCSize.js:174
Parameters
Examples
var a = new cc.size(10, 10);
var b = new cc.size(10, 10);
cc.sizeEqualToSize(a, b);// return true;
var b = new cc.size(5, 10);
cc.sizeEqualToSize(a, b);// return false;
V3F_C4B_T2F_QuadZero
meta description
Returns V3F_C4B_T2F_Quad
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCTypesWebGL.js:501
V3F_C4B_T2F_QuadCopy
meta description
Returns V3F_C4B_T2F_Quad
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCTypesWebGL.js:509
Parameters
V3F_C4B_T2F_QuadsCopy
meta description
Returns Array
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCTypesWebGL.js:536
Parameters
v2

The convenience method to create a new cc.Vec2.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCVec2.js:592
Parameters
Examples
var v1 = cc.v2();
var v2 = cc.v2(0, 0);
var v3 = cc.v2(v2);
var v4 = cc.v2({x: 100, y: 100});
p

The convenience method to creates a new cc.Vec2.

meta description
Returns Vec2
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCVec2.js:609
Parameters
Examples
var point1 = cc.p();
var point2 = cc.p(100, 100);
var point3 = cc.p(point2);
var point4 = cc.p({x: 100, y: 100});
pointEqualToPoint

Check whether a point's value equals to another.

meta description
Returns Boolean
Defined in https:/github.com/cocos-creator/engine/blob/master/cocos2d/core/value-types/CCVec2.js:627
Parameters

results matching ""

    No results matching ""