Cocos Creator API

1.3.0

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

cc

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

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

dragonBonesJson string

atlasJson string

texture cc.Texture2D

Integer string readOnly

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 readOnly

Indicates that the elements in array should be type double.

Boolean string readOnly

Indicates that the elements in array should be type boolean.

String string readOnly

Indicates that the elements in array should be type string.

_initDebugSetting
(
  • mode
)

Init Debug setting.

mode DebugMode

error
(
  • obj
  • subst
)

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.
obj 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
(
  • obj
  • subst
)

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.
obj 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
(
  • obj
  • subst
)

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

obj 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
(
  • obj
  • subst
)

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.
obj 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
(
  • action
  • speed
)
Action

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.

action ActionInterval
speed Number

:

: Action

:

// change the target action speed;
var action = cc.scaleTo(0.2, 1, 0.6);
var newAction = cc.speed(action, 0.5);

follow
(
  • followedNode
  • rect
)
Action | Null

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

followedNode Node
rect Rect

:

: Action | Null

returns the cc.Follow object on success

:

// 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
)

Points setter

points Array

cardinalSplineTo
(
  • duration
  • points
  • tension
)
ActionInterval

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

duration Number
points Array

array of control points

tension Number

:

//create a cc.CardinalSplineTo
var action1 = cc.cardinalSplineTo(3, array, 0);

updatePosition
(
  • newPos
)

update position of target

newPos Vec2

cardinalSplineBy
(
  • duration
  • points
  • tension
)
ActionInterval

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

duration Number
points Array
tension Number

catmullRomTo
(
  • dt
  • points
)
ActionInterval

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

dt Number
points Array

:

var action1 = cc.catmullRomTo(3, array);

catmullRomBy
(
  • dt
  • points
)
ActionInterval

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

dt Number
points Array

:

var action1 = cc.catmullRomBy(3, array);

easeIn
(
  • rate
)
Object

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

rate Number

:

: Object

:

// example
action.easing(cc.easeIn(3.0));

easeOut
(
  • rate
)
Object

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

rate Number

:

: Object

:

// example
action.easing(cc.easeOut(3.0));

easeInOut
(
  • rate
)
Object

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

rate Number

:

: Object

:

//The new usage
action.easing(cc.easeInOut(3.0));

easeExponentialIn ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeExponentialIn());

easeExponentialOut ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeExponentialOut());

easeExponentialInOut ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeExponentialInOut());

easeSineIn ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeSineIn());

easeSineOut ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeSineOut());

easeSineInOut ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeSineInOut());

easeElasticIn
(
  • period
)
Object

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

period Number

:

: Object

:

// example
action.easing(cc.easeElasticIn(3.0));

easeElasticOut
(
  • period
)
Object

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

period Number

:

: Object

:

// example
action.easing(cc.easeElasticOut(3.0));

easeElasticInOut
(
  • period
)
Object

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

period Number

:

: Object

:

// example
action.easing(cc.easeElasticInOut(3.0));

easeBounceIn ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeBounceIn());

easeBounceOut ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeBounceOut());

easeBounceInOut ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeBounceInOut());

easeBackIn ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeBackIn());

easeBackOut ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeBackOut());

easeBackInOut ( ) Object

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

:

: Object

:

// example
action.easing(cc.easeBackInOut());

easeBezierAction
(
  • p0
  • p1
  • p2
  • p3
)
Object

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

p0 Number

The first bezier parameter

p1 Number

The second bezier parameter

p2 Number

The third bezier parameter

p3 Number

The fourth bezier parameter

:

: Object

:

// example
action.easing(cc.easeBezierAction(0.5, 0.5, 1.0, 1.0));

easeQuadraticActionIn ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeQuadraticActionIn());

easeQuadraticActionOut ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeQuadraticActionOut());

easeQuadraticActionInOut ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeQuadraticActionInOut());

easeQuarticActionIn ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeQuarticActionIn());

easeQuarticActionOut ( ) Object

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

:

: Object

:

//example
action.easing(cc.QuarticActionOut());

easeQuarticActionInOut ( ) Object

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

:

: Object

easeQuinticActionIn ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeQuinticActionIn());

easeQuinticActionOut ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeQuadraticActionOut());

easeQuinticActionInOut ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeQuinticActionInOut());

easeCircleActionIn ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeCircleActionIn());

easeCircleActionOut ( ) Object

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

:

: Object

easeCircleActionInOut ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeCircleActionInOut());

easeCubicActionIn ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeCubicActionIn());

easeCubicActionOut ( ) Object

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

:

: Object

:

//example
action.easing(cc.easeCubicActionOut());

easeCubicActionInOut ( ) Object

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

:

: Object

show ( ) ActionInstant

Show the Node.

:

// example
var showAction = cc.show();

hide ( ) ActionInstant

Hide the node.

:

// example
var hideAction = cc.hide();

toggleVisibility ( ) ActionInstant

Toggles the visibility of a node.

:

// example
var toggleVisibilityAction = cc.toggleVisibility();

removeSelf
(
  • isNeedCleanUp
)
ActionInstant

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

isNeedCleanUp Boolean

:

// example
var removeSelfAction = cc.removeSelf();

flipX
(
  • flip
)
ActionInstant

Create a FlipX action to flip or unflip the target.

flip Boolean

Indicate whether the target should be flipped or not

:

var flipXAction = cc.flipX(true);

flipY
(
  • flip
)
ActionInstant

Create a FlipY action to flip or unflip the target.

flip Boolean

:

var flipYAction = cc.flipY(true);

place
(
  • pos
  • [y ]
)
ActionInstant

Creates a Place action with a position.

pos Vec2 | Number
y optional Number

:

// example
var placeAction = cc.place(cc.p(200, 200));
var placeAction = cc.place(200, 200);

callFunc
(
  • selector
  • [selectorTarget ]
  • [data ]
)
ActionInstant

Creates the action with the callback.

selector function
selectorTarget optional object | Null
data optional | Null

data for function, it accepts all data types.

:

// example
// CallFunc without data
var finish = cc.callFunc(this.removeSprite, this);

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

sequence
(
  • tempArray
)
ActionInterval

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

tempArray Array | FiniteTimeAction

:

// example
// create sequence with actions
var seq = cc.sequence(act1, act2);

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

repeat
(
  • action
  • times
)
ActionInterval

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

action FiniteTimeAction
times Number

:

// example
var rep = cc.repeat(cc.sequence(jump2, jump1), 5);

repeatForever
(
  • action
)
ActionInterval

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

:

// example
var repeat = cc.repeatForever(cc.rotateBy(1.0, 360));

spawn
(
  • tempArray
)
FiniteTimeAction

Create a spawn action which runs several actions in parallel.

tempArray Array | FiniteTimeAction

:

// 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
(
  • duration
  • deltaAngleX
  • [deltaAngleY ]
)
ActionInterval

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

duration Number

duration in seconds

deltaAngleX Number

deltaAngleX in degrees.

deltaAngleY optional Number

deltaAngleY in degrees.

:

// example
var rotateTo = cc.rotateTo(2, 61.0);

rotateBy
(
  • duration
  • deltaAngleX
  • [deltaAngleY ]
)
ActionInterval

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

duration Number

duration in seconds

deltaAngleX Number

deltaAngleX in degrees

deltaAngleY optional Number

deltaAngleY in degrees

:

// example
var actionBy = cc.rotateBy(2, 360);

moveBy
(
  • duration
  • deltaPos
  • deltaY
)
ActionInterval

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.

duration Number

duration in seconds

deltaPos Vec2 | Number
deltaY Number

:

// example
var actionTo = cc.moveBy(2, cc.p(windowSize.width - 40, windowSize.height - 40));

moveTo
(
  • duration
  • position
  • y
)
ActionInterval

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.

duration Number

duration in seconds

position Vec2
y Number

:

// example
var actionBy = cc.moveTo(2, cc.p(80, 80));

skewTo
(
  • t
  • sx
  • sy
)
ActionInterval

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

t Number

time in seconds

sx Number
sy Number

:

// example
var actionTo = cc.skewTo(2, 37.2, -37.2);

skewBy
(
  • t
  • sx
  • sy
)
ActionInterval

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

t Number

time in seconds

sx Number

sx skew in degrees for X axis

sy Number

sy skew in degrees for Y axis

:

// example
var actionBy = cc.skewBy(2, 0, -90);

jumpBy
(
  • duration
  • position
  • [y ]
  • height
  • jumps
)
ActionInterval

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

duration Number
position Vec2 | Number
y optional Number
height Number
jumps Number

:

// example
var actionBy = cc.jumpBy(2, cc.p(300, 0), 50, 4);
var actionBy = cc.jumpBy(2, 300, 0, 50, 4);

jumpTo
(
  • duration
  • position
  • [y ]
  • height
  • jumps
)
ActionInterval

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

duration Number
position Vec2 | Number
y optional Number
height Number
jumps Number

:

// example
var actionTo = cc.jumpTo(2, cc.p(300, 300), 50, 4);
var actionTo = cc.jumpTo(2, 300, 300, 50, 4);

bezierBy
(
  • t
  • c
)
ActionInterval

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

t Number

time in seconds

c Array

Array of points

:

// 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
(
  • t
  • c
)
ActionInterval

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

t Number
c Array

array of points

:

// 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
(
  • duration
  • sx
  • [sy ]
)
ActionInterval

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

duration Number
sx Number

scale parameter in X

sy optional Number

scale parameter in Y, if Null equal to sx

:

// 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
(
  • duration
  • sx
  • [sy ]
)
ActionInterval

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

duration Number

duration in seconds

sx Number

sx scale parameter in X

sy optional Number | Null

sy scale parameter in Y, if Null equal to sx

:

// 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);

blink
(
  • duration
  • blinks
)
ActionInterval

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

duration Number

duration in seconds

blinks Number

blinks in times

:

// example
var action = cc.blink(2, 10);

fadeTo
(
  • duration
  • opacity
)
ActionInterval

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

duration Number
opacity Number

0-255, 0 is transparent

:

// example
var action = cc.fadeTo(1.0, 0);

fadeIn
(
  • duration
)
ActionInterval

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

duration Number

duration in seconds

:

//example
var action = cc.fadeIn(1.0);

fadeOut
(
  • d
)
ActionInterval

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

d Number

duration in seconds

:

// example
var action = cc.fadeOut(1.0);

tintTo
(
  • duration
  • red
  • green
  • blue
)
ActionInterval

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

duration Number
red Number

0-255

green Number

0-255

blue Number

0-255

:

// example
var action = cc.tintTo(2, 255, 0, 255);

tintBy
(
  • duration
  • deltaRed
  • deltaGreen
  • deltaBlue
)
ActionInterval

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

duration Number

duration in seconds

deltaRed Number
deltaGreen Number
deltaBlue Number

:

// example
var action = cc.tintBy(2, -127, -255, -127);

delayTime
(
  • d
)
ActionInterval

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

d Number

duration in seconds

:

// example
var delay = cc.delayTime(1);

reverseTime
(
  • action
)
ActionInterval

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

:

// example
 var reverse = cc.reverseTime(this);

targetedAction
(
  • target
  • action
)
ActionInterval

Create an action with the specified action and forced target.

target Node
action FiniteTimeAction

HashElement ( )

Constructor

isChildClassOf
(
  • subclass
  • superclass
)
Boolean

Checks whether subclass is child of superclass or equals to superclass

subclass Function
superclass Function

:

Class
(
  • [options ]
)
Function

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

options optional Object
  • name String optional

    The class name used for serialization.

  • extends Function optional

    The base class.

  • ctor Function optional

    The constructor.

  • properties Object optional

    The property definitions.

  • statics Object optional

    The static members.

  • mixins Function[] optional
  • editor Object optional

    attributes for Component listed below.

    • requireComponent Component optional
      Automatically add required component as a dependency.
    • disallowMultiple Component optional
      If specified to a type, prevents Component of the same type (or subtype) to be added more than once to a Node.
    • menu String optional
      The menu path to register a component to the editors "Component" menu. Eg. "Rendering/Camera".
    • executeInEditMode Boolean optional
      Makes a component execute in edit mode. By default, all components are only executed in play mode, which means they will not have their callback functions executed while the Editor is in edit mode.
    • playOnFocus Boolean optional
      This property is only available if executeInEditMode is true. 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 optional
      Specifying the url of the custom html to draw the component in inspector.
    • icon String optional
      Specifying the url of the icon to display in inspector.
    • help String optional
      The custom documentation UR
  • update Function optional

    lifecycle method for Component, see update

  • lateUpdate Function optional

    lifecycle method for Component, see lateUpdate

  • onLoad Function optional

    lifecycle method for Component, see onLoad

  • start Function optional

    lifecycle method for Component, see start

  • onEnable Function optional

    lifecycle method for Component, see onEnable

  • onDisable Function optional

    lifecycle method for Component, see onDisable

  • onDestroy Function optional

    lifecycle method for Component, see onDestroy

  • onFocusInEditor Function optional

    lifecycle method for Component, see onFocusInEditor

  • onLostFocusInEditor Function optional

    lifecycle method for Component, see onLostFocusInEditor

  • onRestore Function optional

    for Component only, see onRestore

  • _getLocalBounds Function optional

    for Component only, see _getLocalBounds

:

: Function

the created class

:

// 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;
},

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();

// define static member

Sprite.count = 0;
Sprite.getBounds = function (spriteList) {
// ...
};

_isCCClass
(
  • constructor
)
Boolean private

Checks whether the constructor is created by cc.Class

constructor Function

:

getInheritanceChain
(
  • constructor
)
Function[]

Return all super classes

constructor Function

setAccelerometerEnabled
(
  • isEnable
)

whether enable accelerometer event

isEnable Boolean

setAccelerometerInterval
(
  • interval
)

set accelerometer interval value

interval Number

isValid
(
  • value
)
Boolean

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

value Any

:

: Boolean

whether is valid

:

cc.log(cc.isValid(target));

deserialize
(
  • data
  • [result ]
  • [options ]
)
object

Deserialize json to cc.Asset

data String | Object

the serialized cc.Asset json string or json object.

result optional Details

additional loading result

options optional Object

:

: object

the main data(asset)

instantiate
(
  • original
)
Object

Clones the object original and returns the clone.

See Clone exists Entity

original Object

An existing object that you want to make a copy of.

:

: Object

the newly instantiated object

find
(
  • path
  • [referenceNode ]
)
Node static

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.

path String
referenceNode optional Node

:

: Node

the node or null if not found

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

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

r optional Number 0
g optional Number 0
b optional Number 0
a optional Number 255

:

: Color

:

-----------------------
// 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
(
  • color1
  • color2
)
Boolean

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

color1 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.

  • a Number optional , default: 255

    alpha component of the color, default value is 255.

color2 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.

  • a Number optional , default: 255

    alpha component of the color, default value is 255.

:

: Boolean

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

:

cc.log(cc.colorEqual(cc.Color.RED, new cc.Color(255, 0, 0))); // true

hexToColor
(
  • hex
)
Color

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

hex String

:

: Color

:

cc.hexToColor("#FFFF33"); // Color {r: 255, g: 255, b: 51, a: 255};

colorToHex
(
  • color
)
String

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

color 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.

  • a Number optional , default: 255

    alpha component of the color, default value is 255.

:

: String

:

var color = new cc.Color(255, 6, 255)
cc.colorToHex(color); // #ff06ff;

Enum
(
  • obj
)
object

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.

obj object

a JavaScript literal object containing enum names and values

:

: object

the defined enum type

:

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,
});

getList
(
  • enumDef
)
Object[] private

enumDef Object

the enum type defined from cc.Enum

:

pNeg
(
  • point
)
Vec2

Returns opposite of Vec2.

point Vec2

:

: Vec2

:

cc.pNeg(cc.v2(10, 10));// Vec2 {x: -10, y: -10};

pAdd
(
  • v1
  • v2
)
Vec2

Calculates sum of two points.

v1 Vec2
v2 Vec2

:

: Vec2

:

cc.pAdd(cc.v2(1, 1), cc.v2(2, 2));// Vec2 {x: 3, y: 3};

pSub
(
  • v1
  • v2
)
Vec2

Calculates difference of two points.

v1 Vec2
v2 Vec2

:

: Vec2

:

cc.pSub(cc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 15, y: 15};

pMult
(
  • point
  • floatVar
)
Vec2

Returns point multiplied by given factor.

point Vec2
floatVar Number

:

: Vec2

:

cc.pMult(cc.v2(5, 5), 4); // Vec2 {x: 20, y: 20};

pMidpoint
(
  • v1
  • v2
)
Vec2

Calculates midpoint between two points.

v1 Vec2
v2 Vec2

:

: Vec2

:

cc.pMidpoint(cc.v2(10, 10), cc.v2(5, 5)); // Vec2 {x: 7.5, y: 7.5};

pDot
(
  • v1
  • v2
)
Number

Calculates dot product of two points.

v1 Vec2
v2 Vec2

:

: Number

:

cc.pDot(cc.v2(20, 20), cc.v2(5, 5)); // 200;

pCross
(
  • v1
  • v2
)
Number

Calculates cross product of two points.

v1 Vec2
v2 Vec2

:

: Number

:

cc.pCross(cc.v2(20, 20), cc.v2(5, 5)); // 0;

pPerp
(
  • point
)
Vec2

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

point Vec2

:

: Vec2

:

cc.pPerp(cc.v2(20, 20)); // Vec2 {x: -20, y: 20};

pRPerp
(
  • point
)
Vec2

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

point Vec2

:

: Vec2

:

cc.pRPerp(cc.v2(20, 20)); // Vec2 {x: 20, y: -20};

pProject
(
  • v1
  • v2
)
Vec2

Calculates the projection of v1 over v2.

v1 Vec2
v2 Vec2

:

: Vec2

:

var v1 = cc.v2(20, 20);
var v2 = cc.v2(5, 5);
cc.pProject(v1, v2); // Vec2 {x: 20, y: 20};

pLengthSQ
(
  • v
)
Number

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

v Vec2

:

: Number

:

cc.pLengthSQ(cc.v2(20, 20)); // 800;

pDistanceSQ
(
  • point1
  • point2
)
Number

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

point1 Vec2
point2 Vec2

:

: Number

:

var point1 = cc.v2(20, 20);
var point2 = cc.v2(5, 5);
cc.pDistanceSQ(point1, point2); // 450;

pLength
(
  • v
)
Number

Calculates distance between point an origin.

v Vec2

:

: Number

:

cc.pLength(cc.v2(20, 20)); // 28.284271247461902;

pDistance
(
  • v1
  • v2
)
Number

Calculates the distance between two points.

v1 Vec2
v2 Vec2

:

: Number

:

var v1 = cc.v2(20, 20);
var v2 = cc.v2(5, 5);
cc.pDistance(v1, v2); // 21.213203435596427;

pNormalize
(
  • v
)
Vec2

Returns this vector with a magnitude of 1.

v Vec2

:

: Vec2

:

cc.pNormalize(cc.v2(20, 20)); // Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};

pForAngle
(
  • a
)
Vec2

Converts radians to a normalized vector.

a Number

:

: Vec2

:

cc.pForAngle(20); // Vec2 {x: 0.40808206181339196, y: 0.9129452507276277};

pToAngle
(
  • v
)
Number

Converts a vector to radians.

v Vec2

:

: Number

:

cc.pToAngle(cc.v2(20, 20)); // 0.7853981633974483;

clampf
(
  • value
  • min_inclusive
  • max_inclusive
)
Number

Clamp a value between from and to.

value Number
min_inclusive Number
max_inclusive Number

:

: Number

:

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
(
  • value
)
Number

Clamp a value between 0 and 1.

value Number

:

: Number

:

var v1 = cc.clampf(20);  // 1;
var v2 = cc.clampf(-1);  // 0;
var v3 = cc.clampf(0.5); // 0.5;

pClamp
(
  • p
  • min_inclusive
  • max_inclusive
)
Vec2

Clamp a point between from and to.

p Vec2
min_inclusive Vec2
max_inclusive Vec2

:

: Vec2

:

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
(
  • s
)
Vec2

Quickly convert cc.Size to a cc.Vec2.

s Size

:

: Vec2

:

cc.pFromSize(new cc.size(20, 20)); // Vec2 {x: 20, y: 20};

pCompOp
(
  • p
  • opFunc
)
Vec2

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

p Vec2
opFunc Function

:

: Vec2

:

cc.pCompOp(cc.p(-10, -10), Math.abs); // Vec2 {x: 10, y: 10};

pLerp
(
  • a
  • b
  • alpha
)
Vec2

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

a Vec2
b Vec2
alpha Number

:

: Vec2

:

cc.pLerp(cc.v2(20, 20), cc.v2(5, 5), 0.5); // Vec2 {x: 12.5, y: 12.5};

pFuzzyEqual
(
  • a
  • b
  • variance
)
Boolean

TODO

a Vec2
b Vec2
variance Number

:

: Boolean

if points have fuzzy equality which means equal with some degree of variance.

:

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
(
  • a
  • b
)
Vec2

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

a Vec2
b Vec2

:

: Vec2

:

cc.pCompMult(acc.v2(20, 20), cc.v2(5, 5)); // Vec2 {x: 100, y: 100};

pAngleSigned
(
  • a
  • b
)
Number

TODO

a Vec2
b Vec2

:

: Number

the signed angle in radians between two vector directions

pAngle
(
  • a
  • b
)
Number

TODO

a Vec2
b Vec2

:

: Number

the angle in radians between two vector directions

pRotateByAngle
(
  • v
  • pivot
  • angle
)
Vec2

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

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

:

: Vec2

the rotated point

pLineIntersect
(
  • A
  • B
  • C
  • D
  • retP
)
Boolean

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);

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
(
  • A
  • B
  • C
  • D
)
Boolean

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

A Vec2
B Vec2
C Vec2
D Vec2

:

pIntersectPoint
(
  • A
  • B
  • C
  • D
)
Vec2

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

A Vec2
B Vec2
C Vec2
D Vec2

:

: Vec2

pSameAs
(
  • A
  • B
)
Boolean

check to see if both points are equal.

A Vec2

A ccp a

B Vec2

B ccp b to be compared

:

: Boolean

the true if both ccp are same

pZeroIn
(
  • v
)

sets the position of the point to 0.

v Vec2

pIn
(
  • v1
  • v2
)

copies the position of one point to another.

v1 Vec2
v2 Vec2

pMultIn
(
  • point
  • floatVar
)

multiplies the point with the given factor (inplace).

point Vec2
floatVar Number

pSubIn
(
  • v1
  • v2
)

subtracts one point from another (inplace).

v1 Vec2
v2 Vec2

pAddIn
(
  • v1
  • v2
)

adds one point to another (inplace).

v1 Vec2
v2 Vec2

pNormalizeIn
(
  • v
)

normalizes the point (inplace).

v Vec2

rect
(
  • [x =0]
  • [y =0]
  • [w =0]
  • [h =0]
)
Rect

The convenience method to create a new Rect. see cc.Rect

x optional Number[] | Number 0
y optional Number 0
w optional Number 0
h optional Number 0

:

: Rect

:

var a = new cc.rect(0 , 0, 10, 0);

rectEqualToRect
(
  • rect1
  • rect2
)
Boolean

Check whether a rect's value equals to another.

rect1 Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0
rect2 Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

:

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
(
  • rect1
  • rect2
)
Boolean

Check whether the rect1 contains rect2.

rect1 Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0
rect2 Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

:

var a = new cc.rect(0, 0, 20, 20);
var b = new cc.rect(10, 10, 20, 20);
cc.rectContainsRect(a, b); // true;

rectGetMaxX
(
  • rect
)
Number

Returns the rightmost x-value of a rect.

rect Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

: Number

The rightmost x value.

:

var a = new cc.rect(10, 0, 20, 20);
cc.rectGetMaxX(a); // 30;

rectGetMidX
(
  • rect
)
Number

Return the midpoint x-value of a rect.

rect Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

: Number

The midpoint x value.

:

var a = new cc.rect(10, 0, 20, 20);
cc.rectGetMidX(a); // 20;

rectGetMinX
(
  • rect
)
Number

Returns the leftmost x-value of a rect.

rect Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

: Number

The leftmost x value.

:

var a = new cc.rect(10, 0, 20, 20);
cc.rectGetMinX(a); // 10;

rectGetMaxY
(
  • rect
)
Number

Return the topmost y-value of a rect.

rect Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

: Number

The topmost y value.

:

var a = new cc.rect(0, 10, 20, 20);
cc.rectGetMaxY(a); // 30;

rectGetMidY
(
  • rect
)
Number

Return the midpoint y-value of `rect'.

rect Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

: Number

The midpoint y value.

:

var a = new cc.rect(0, 10, 20, 20);
cc.rectGetMidY(a); // 20;

rectGetMinY
(
  • rect
)
Number

Return the bottommost y-value of a rect.

rect Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

: Number

The bottommost y value.

:

var a = new cc.rect(0, 10, 20, 20);
cc.rectGetMinY(a); // 10;

rectContainsPoint
(
  • rect
  • point
)
Boolean

Check whether a rect contains a point.

rect Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0
point Vec2

:

:

var a = new cc.rect(0, 10, 20, 20);
var b = cc.v2(0, 10, 10, 10);
cc.rectContainsPoint(a, b); // true;

rectIntersectsRect
(
  • rectA
  • rectB
)
Boolean

Check whether a rect intersect with another.

rectA Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0
rectB Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

:

var a = new cc.rect(0, 10, 20, 20);
var b = new cc.rect(0, 10, 10, 10);
cc.rectIntersectsRect(a, b); // true;

rectOverlapsRect
(
  • rectA
  • rectB
)
Boolean

Check whether a rect overlaps another.

rectA Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0
rectB Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

:

var a = new cc.rect(0, 10, 20, 20);
var b = new cc.rect(0, 10, 10, 10);
cc.rectOverlapsRect(a, b); // true;

rectUnion
(
  • rectA
  • rectB
)
Rect

Returns the smallest rectangle that contains the two source rectangles.

rectA Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0
rectB Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

: Rect

:

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
(
  • rectA
  • rectB
)
Rect

Returns the overlapping portion of 2 rectangles.

rectA Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0
rectB Rect

!#en Constructor of cc.Rect class. see cc.rect for convenience method. !#zh cc.Rect类的构造函数。可以通过 cc.rect 简便方法进行创建。

  • x Number optional , default: 0
  • y Number optional , default: 0
  • w Number optional , default: 0
  • h Number optional , default: 0

:

: Rect

:

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};

V3F_C4B_T2F_QuadZero ( ) V3F_C4B_T2F_Quad

V3F_C4B_T2F_QuadCopy
(
  • sourceQuad
)
V3F_C4B_T2F_Quad

sourceQuad V3F_C4B_T2F_Quad

V3F_C4B_T2F_QuadsCopy
(
  • sourceQuads
)
Array

sourceQuads Array

:

: Array

v2
(
  • [x =0]
  • [y =0]
)
Vec2

The convenience method to create a new cc.Vec2.

x optional Number | Object 0
y optional Number 0

:

: Vec2

:

var v1 = cc.v2();
var v2 = cc.v2(0, 0);
var v3 = cc.v2(v2);
var v4 = cc.v2({x: 100, y: 100});

p
(
  • [x =0]
  • [y =0]
)
Vec2

The convenience method to creates a new cc.Vec2.

x optional Number | Object 0

a Number or a size object

y optional Number 0

:

: Vec2

:

var point1 = cc.p();
var point2 = cc.p(100, 100);
var point3 = cc.p(point2);
var point4 = cc.p({x: 100, y: 100});

pointEqualToPoint
(
  • point1
  • point2
)
Boolean

Check whether a point's value equals to another.

point1 Vec2

!#en Constructor see Cc/vec2:method or cc.p !#zh 构造函数,可查看 Cc/vec2:method 或者 cc.p

  • x number optional , default: 0
  • y number optional , default: 0
point2 Vec2

!#en Constructor see Cc/vec2:method or cc.p !#zh 构造函数,可查看 Cc/vec2:method 或者 cc.p

  • x number optional , default: 0
  • y number optional , default: 0

: