Cocos Creator API

1.4.x

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

Module js

This module provides some JavaScript utilities. All members can be accessed with cc.js

Class

Methods

isNumber
(
  • obj
)
Boolean

Check the obj whether is number or not If a number is created by using 'new Number(10086)', the typeof it will be "object"... Then you can use this function if you care about this case.

name type description
obj Any

returns:

type: Boolean

isString
(
  • obj
)
Boolean

Check the obj whether is string or not. If a string is created by using 'new String("blabla")', the typeof it will be "object"... Then you can use this function if you care about this case.

name type description
obj Any

returns:

type: Boolean

addon
(
  • obj
  • sourceObj
)
Object deprecated

This method is deprecated, use cc.js.mixin please.
Copy all properties not defined in obj from arguments[1...n]

name type description
obj Object

object to extend its properties

sourceObj Object

source object to copy properties from

returns:

type: Object

the result obj

mixin
(
  • obj
  • sourceObj
)
Object

copy all properties from arguments[1...n] to obj

name type description
obj Object
sourceObj Object

returns:

type: Object

the result obj

extend
(
  • cls
  • base
)
Function

Derive the class from the supplied base class. Both classes are just native javascript constructors, not created by cc.Class, so usually you will want to inherit using cc.Class instead.

name type description
cls Function
base Function

the baseclass to inherit