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

:

: