Options
All
  • Public
  • Public/Protected
  • All
Menu

External module data

Index

Classes

Interfaces

Type aliases

Variables

Functions

Object literals

Type aliases

OnAfterProp

OnAfterProp: function

Type declaration

    • (constructor: Function, mainPropertyName: string): void
    • Parameters

      • constructor: Function
      • mainPropertyName: string

      Returns void

PropertyType

SimplePropertyType

SimplePropertyType: Function | string | PrimitiveType | PrimitiveType | PrimitiveType | PrimitiveType

Variables

Const BUILTIN_ENTRIES

BUILTIN_ENTRIES: string[] = ['name', 'extends', 'mixins', 'ctor', '__ctor__', 'properties', 'statics', 'editor', '__ES6__']

Const CACHE_KEY

CACHE_KEY: "__ccclassCache__" = "__ccclassCache__"

Const DEFAULT

DEFAULT: string = Attr.DELIMETER + 'default'

Const DELIMETER

DELIMETER: "$_$" = attributeUtils.DELIMETER

Const Deactivating

Deactivating: number = 1 << 8

Const Destroyed

Destroyed: any = CCObject.Flags.Destroyed

Const Destroyed

Destroyed: any = CCObject.Flags.Destroyed

Const Destroyed

Destroyed: number = 1 << 0

Const Destroying

Destroying: number = 1 << 7

Const Dirty

Dirty: number = 1 << 5

Const DontDestroy

DontDestroy: number = 1 << 6

Const DontSave

DontSave: number = 1 << 3

Const EditorOnly

EditorOnly: number = 1 << 4

Const HideInHierarchy

HideInHierarchy: number = 1 << 10

Const IDENTIFIER_RE

IDENTIFIER_RE: RegExp = CCClass.IDENTIFIER_RE

Const IDENTIFIER_RE

IDENTIFIER_RE: RegExp = /^[A-Za-z_$][0-9A-Za-z_$]*$/

Const INVALID_STATICS_DEV

INVALID_STATICS_DEV: string[] = ['name', '__ctors__', '__props__', 'arguments', 'call', 'apply', 'caller', 'length', 'prototype']

Const IsAnchorLocked

IsAnchorLocked: number = 1 << 19

Const IsEditorOnEnableCalled

IsEditorOnEnableCalled: number = 1 << 12

Const IsOnEnableCalled

IsOnEnableCalled: number = 1 << 11

Const IsOnLoadCalled

IsOnLoadCalled: number = 1 << 14

Const IsOnLoadStarted

IsOnLoadStarted: number = 1 << 15

Const IsPositionLocked

IsPositionLocked: number = 1 << 21

Const IsPreloadStarted

IsPreloadStarted: number = 1 << 13

Const IsRotationLocked

IsRotationLocked: number = 1 << 17

Const IsScaleLocked

IsScaleLocked: number = 1 << 18

Const IsSizeLocked

IsSizeLocked: number = 1 << 20

Const IsStartCalled

IsStartCalled: number = 1 << 16

Const LINE_INDEX_OF_NEW_OBJ

LINE_INDEX_OF_NEW_OBJ: 0 = 0

Const LOCAL_ARRAY

LOCAL_ARRAY: "a" = "a"

Const LOCAL_OBJ

LOCAL_OBJ: "o" = "o"

Const LOCAL_TEMP_OBJ

LOCAL_TEMP_OBJ: "t" = "t"

Const LockedInEditor

LockedInEditor: number = 1 << 9

Const PersistentMask

PersistentMask: any = CCObject.Flags.PersistentMask

Const PersistentMask

PersistentMask: number = ~(ToDestroy | Dirty | Destroying | DontDestroy | Deactivating |IsPreloadStarted | IsOnLoadStarted | IsOnLoadCalled | IsStartCalled |IsOnEnableCalled | IsEditorOnEnableCalled |IsRotationLocked | IsScaleLocked | IsAnchorLocked | IsSizeLocked | IsPositionLocked/*RegisteredInEditor*/)

Const PersistentMask

PersistentMask: any = CCObject.Flags.PersistentMask

Const RealDestroyed

RealDestroyed: number = 1 << 1

Const SuperCallReg

SuperCallReg: RegExp = superCllRegCondition ? /\b\._super\b/ : /.*/

Const SuperCallRegStrict

SuperCallRegStrict: RegExp = superCllRegCondition ? /this\._super\s*\(/ : /(NONE){99}/

Const ToDestroy

ToDestroy: number = 1 << 2

Const VAR

VAR: "var " = "var "

Const _createCtor

_createCtor: (Anonymous function) = SUPPORT_JIT ? function (ctors, baseClass, className, options) {const superCallBounded = baseClass && boundSuperCalls(baseClass, options, className);const ctorName = DEV ? normalizeClassName_DEV(className) : 'CCClass';let body = 'return function ' + ctorName + '(){\n';if (superCallBounded) {body += 'this._super=null;\n';}// instantiate propsbody += 'this.__initProps__(' + ctorName + ');\n';// call user constructorsconst ctorLen = ctors.length;if (ctorLen > 0) {const useTryCatch = DEV && !(className && className.startsWith('cc.'));if (useTryCatch) {body += 'try{\n';}const SNIPPET = '].apply(this,arguments);\n';if (ctorLen === 1) {body += ctorName + '.__ctors__[0' + SNIPPET;}else {body += 'var cs=' + ctorName + '.__ctors__;\n';for (let i = 0; i < ctorLen; i++) {body += 'cs[' + i + SNIPPET;}}if (useTryCatch) {body += '}catch(e){\n' +'cc._throw(e);\n' +'}\n';}}body += '}';return Function(body)();} : function (ctors, baseClass, className, options) {const superCallBounded = baseClass && boundSuperCalls(baseClass, options, className);const ctorLen = ctors.length;let Class;if (ctorLen > 0) {if (superCallBounded) {if (ctorLen === 2) {// User ComponentClass = function (this: any) {this._super = null;this.__initProps__(Class);ctors[0].apply(this, arguments);ctors[1].apply(this, arguments);};}else {Class = function (this: any) {this._super = null;this.__initProps__(Class);for (let i = 0; i < ctors.length; ++i) {ctors[i].apply(this, arguments);}};}}else {if (ctorLen === 3) {// NodeClass = function (this: any) {this.__initProps__(Class);ctors[0].apply(this, arguments);ctors[1].apply(this, arguments);ctors[2].apply(this, arguments);};}else {Class = function (this: any) {this.__initProps__(Class);const ctors = Class.__ctors__;for (let i = 0; i < ctors.length; ++i) {ctors[i].apply(this, arguments);}};}}}else {Class = function (this: any) {if (superCallBounded) {this._super = null;}this.__initProps__(Class);};}return Class;}

Const boolean

boolean: function = type(CCBoolean)

将该属性标记为 cc 布尔值。

Type declaration

    • (target: Object, propertyKey: string | symbol): void
    • Parameters

      • target: Object
      • propertyKey: string | symbol

      Returns void

Const ccclass

ccclass: (Anonymous function) = checkCtorArgument(function (ctor, name) {// if (FIX_BABEL6) {// eval('if(typeof _classCallCheck==="function"){_classCallCheck=function(){};}');// }let base = js.getSuper(ctor);if (base === Object) {base = null;}const proto = {name,extends: base,ctor,__ES6__: true,};const cache = ctor[CACHE_KEY];if (cache) {const decoratedProto = cache.proto;if (decoratedProto) {// decoratedProto.properties = createProperties(ctor, decoratedProto.properties);js.mixin(proto, decoratedProto);}ctor[CACHE_KEY] = undefined;}const res = cc.Class(proto);// validate methodsif (DEV) {const propNames = Object.getOwnPropertyNames(ctor.prototype);for (let i = 0; i < propNames.length; ++i) {const prop = propNames[i];if (prop !== 'constructor') {const desc = Object.getOwnPropertyDescriptor(ctor.prototype, prop);const func = desc && desc.value;if (typeof func === 'function') {doValidateMethodWithProps_DEV(func, prop, js.getClassName(ctor), ctor, base);}}}}return res;})

将标准写法的 ES6 Class 声明为 CCClass,具体用法请参阅类型定义

method

ccclass

param

The class name used for serialization.

example
const {ccclass} = cc._decorator;

// define a CCClass, omit the name
 @ccclass
class NewScript extends cc.Component {
    // ...
}

// define a CCClass with a name
 @ccclass('LoginData')
class LoginData {
    // ...
}

Const checkCompArgument

checkCompArgument: function = _checkNormalArgument.bind(null, DEV && function (arg, decoratorName) {if (!cc.Class._isCCClass(arg)) {error('The parameter for %s is missing.', decoratorName);return false;}})

Type declaration

    • (...args: A): R
    • Parameters

      • Rest ...args: A

      Returns R

Const checkNumberArgument

checkNumberArgument: function = _argumentChecker('number')

Type declaration

    • (...args: A): R
    • Parameters

      • Rest ...args: A

      Returns R

Const checkStringArgument

checkStringArgument: function = _argumentChecker('string')

Type declaration

    • (...args: A): R
    • Parameters

      • Rest ...args: A

      Returns R

Const compileDeserialize

compileDeserialize: (Anonymous function) = SUPPORT_JIT ? (self, klass) => {const TYPE = Attr.DELIMETER + 'type';const EDITOR_ONLY = Attr.DELIMETER + 'editorOnly';const DEFAULT = Attr.DELIMETER + 'default';const SAVE_URL_AS_ASSET = Attr.DELIMETER + 'saveUrlAsAsset';const FORMERLY_SERIALIZED_AS = Attr.DELIMETER + 'formerlySerializedAs';const attrs = Attr.getClassAttrs(klass);const props = klass.__values__;// self, obj, serializedData, klass, targetconst sources = ['var prop;',];const fastMode = misc.BUILTIN_CLASSID_RE.test(js._getClassId(klass));// sources.push('var vb,vn,vs,vo,vu,vf;'); // boolean, number, string, object, undefined, function// tslint:disable-next-line: prefer-for-offor (let p = 0; p < props.length; p++) {const propName = props[p];if ((PREVIEW || (EDITOR && self._ignoreEditorOnly)) && attrs[propName + EDITOR_ONLY]) {continue; // skip editor only if in preview}let accessorToSet;let propNameLiteralToSet;if (CCClass.IDENTIFIER_RE.test(propName)) {propNameLiteralToSet = '"' + propName + '"';accessorToSet = '.' + propName;}else {propNameLiteralToSet = CCClass.escapeForJS(propName);accessorToSet = '[' + propNameLiteralToSet + ']';}let accessorToGet = accessorToSet;if (attrs[propName + FORMERLY_SERIALIZED_AS]) {const propNameToRead = attrs[propName + FORMERLY_SERIALIZED_AS];if (CCClass.IDENTIFIER_RE.test(propNameToRead)) {accessorToGet = '.' + propNameToRead;}else {accessorToGet = '[' + CCClass.escapeForJS(propNameToRead) + ']';}}sources.push('prop=d' + accessorToGet + ';');sources.push(`if(typeof ${JSB ? '(prop)' : 'prop'}!=="undefined"){`);const stillUseUrl = attrs[propName + SAVE_URL_AS_ASSET];// function undefined object(null) string boolean numberconst defaultValue = CCClass.getDefault(attrs[propName + DEFAULT]);if (fastMode) {let isPrimitiveType;const userType = attrs[propName + TYPE];if (defaultValue === undefined && userType) {isPrimitiveType = userType === cc.String ||userType === cc.Integer ||userType === cc.Float ||userType === cc.Boolean;}else {const defaultType = typeof defaultValue;isPrimitiveType = (defaultType === 'string' && !stillUseUrl) ||defaultType === 'number' ||defaultType === 'boolean';}if (isPrimitiveType) {sources.push(`o${accessorToSet}=prop;`);}else {compileObjectTypeJit(sources, defaultValue, accessorToSet, propNameLiteralToSet, true, stillUseUrl);}}else {sources.push(`if(typeof ${JSB ? '(prop)' : 'prop'}!=="object"){` +'o' + accessorToSet + '=prop;' +'}else{');compileObjectTypeJit(sources, defaultValue, accessorToSet, propNameLiteralToSet, false, stillUseUrl);sources.push('}');}sources.push('}');}if (cc.js.isChildClassOf(klass, cc._BaseNode) || cc.js.isChildClassOf(klass, cc.Component)) {if (PREVIEW || (EDITOR && self._ignoreEditorOnly)) {const mayUsedInPersistRoot = js.isChildClassOf(klass, cc.Node);if (mayUsedInPersistRoot) {sources.push('d._id&&(o._id=d._id);');}}else {sources.push('d._id&&(o._id=d._id);');}}if (props[props.length - 1] === '_$erialized') {// deep copy original serialized datasources.push('o._$erialized=JSON.parse(JSON.stringify(d));');// parse the serialized data as primitive javascript object, so its __id__ will be dereferencedsources.push('s._deserializePrimitiveObject(o._$erialized,d);');}return Function('s', 'o', 'd', 'k', 't', sources.join(''));} : (self, klass) => {const fastMode = misc.BUILTIN_CLASSID_RE.test(js._getClassId(klass));const shouldCopyId = cc.js.isChildClassOf(klass, cc._BaseNode) || cc.js.isChildClassOf(klass, cc.Component);let shouldCopyRawData;const simpleProps: any = [];let simplePropsToRead = simpleProps;const advancedProps: any = [];let advancedPropsToRead = advancedProps;const advancedPropsUseUrl: any = [];const advancedPropsValueType: any = [];(() => {const props = klass.__values__;shouldCopyRawData = props[props.length - 1] === '_$erialized';const attrs = Attr.getClassAttrs(klass);const TYPE = Attr.DELIMETER + 'type';const DEFAULT = Attr.DELIMETER + 'default';const SAVE_URL_AS_ASSET = Attr.DELIMETER + 'saveUrlAsAsset';const FORMERLY_SERIALIZED_AS = Attr.DELIMETER + 'formerlySerializedAs';// tslint:disable-next-line: prefer-for-offor (let p = 0; p < props.length; p++) {const propName = props[p];let propNameToRead = propName;if (attrs[propName + FORMERLY_SERIALIZED_AS]) {propNameToRead = attrs[propName + FORMERLY_SERIALIZED_AS];}const stillUseUrl = attrs[propName + SAVE_URL_AS_ASSET];// function undefined object(null) string boolean numberconst defaultValue = CCClass.getDefault(attrs[propName + DEFAULT]);let isPrimitiveType = false;if (fastMode) {const userType = attrs[propName + TYPE];if (defaultValue === undefined && userType) {isPrimitiveType = userType === cc.String ||userType === cc.Integer ||userType === cc.Float ||userType === cc.Boolean;}else {const defaultType = typeof defaultValue;isPrimitiveType = (defaultType === 'string' && !stillUseUrl) ||defaultType === 'number' ||defaultType === 'boolean';}}if (fastMode && isPrimitiveType) {if (propNameToRead !== propName && simplePropsToRead === simpleProps) {simplePropsToRead = simpleProps.slice();}simpleProps.push(propName);if (simplePropsToRead !== simpleProps) {simplePropsToRead.push(propNameToRead);}}else {if (propNameToRead !== propName && advancedPropsToRead === advancedProps) {advancedPropsToRead = advancedProps.slice();}advancedProps.push(propName);if (advancedPropsToRead !== advancedProps) {advancedPropsToRead.push(propNameToRead);}advancedPropsUseUrl.push(stillUseUrl);advancedPropsValueType.push((defaultValue instanceof cc.ValueType) && defaultValue.constructor);}}})();return (s, o, d, k, t) => {for (let i = 0; i < simpleProps.length; ++i) {const prop = d[simplePropsToRead[i]];if (prop !== undefined) {o[simpleProps[i]] = prop;}}for (let i = 0; i < advancedProps.length; ++i) {const propName = advancedProps[i];const prop = d[advancedPropsToRead[i]];if (prop === undefined) {continue;}if (!fastMode && typeof prop !== 'object') {o[propName] = prop;}else {// fastMode (so will not simpleProp) or objectconst valueTypeCtor = advancedPropsValueType[i];if (valueTypeCtor) {if (fastMode || prop) {s._deserializeTypedObject(o[propName], prop, valueTypeCtor);}else {o[propName] = null;}}else {if (prop) {s._deserializeObjField(o,prop,propName,(EDITOR || TEST) ? (t && o) : null,advancedPropsUseUrl[i],);}else {o[propName] = null;}}}}if (shouldCopyId && d._id) {o._id = d._id;}if (shouldCopyRawData) {// deep copy original serialized datao._$erialized = JSON.parse(JSON.stringify(d));// parse the serialized data as primitive javascript object, so its __id__ will be dereferenceds._deserializePrimitiveObject(o._$erialized, d);}};}

Let deferredDestroyTimer

deferredDestroyTimer: null = null

Const disallowMultiple

disallowMultiple: any = (DEV ? createEditorDecorator : createDummyDecorator)(checkCtorArgument, 'disallowMultiple')

防止多个相同类型(或子类型)的组件被添加到同一个节点。

method

disallowMultiple

example
const {ccclass, disallowMultiple} = cc._decorator;

 @ccclass
 @disallowMultiple
class CameraCtrl extends cc.Component {
    // ...
}

Const escapeForJS

escapeForJS: escapeForJS = CCClass.escapeForJS

Const executeInEditMode

executeInEditMode: any = (DEV ? createEditorDecorator : createDummyDecorator)(checkCtorArgument, 'executeInEditMode', true)

Makes a CCClass that inherit from 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.
允许继承自 Component 的 CCClass 在编辑器里执行。
默认情况下,所有 Component 都只会在运行时才会执行,也就是说它们的生命周期回调不会在编辑器里触发。

method

executeInEditMode

example
const {ccclass, executeInEditMode} = cc._decorator;

 @ccclass
 @executeInEditMode
class NewScript extends cc.Component {
    // ...
}

Const executionOrder

executionOrder: any = createEditorDecorator(checkNumberArgument, 'executionOrder')

设置脚本生命周期方法调用的优先级。优先级小于 0 的组件将会优先执行,优先级大于 0 的组件将会延后执行。优先级仅会影响 onLoad, onEnable, start, update 和 lateUpdate,而 onDisable 和 onDestroy 不受影响。

method

executionOrder

param

The execution order of lifecycle methods for Component. Those less than 0 will execute before while those greater than 0 will execute after.

example
const {ccclass, executionOrder} = cc._decorator;

 @ccclass
 @executionOrder(1)
class CameraCtrl extends cc.Component {
    // ...
}

Const float

float: function = type(CCFloat)

将该属性标记为 cc 浮点数。

Type declaration

    • (target: Object, propertyKey: string | symbol): void
    • Parameters

      • target: Object
      • propertyKey: string | symbol

      Returns void

Const help

help: any = (DEV ? createEditorDecorator : createDummyDecorator)(checkStringArgument, 'help')

指定当前组件的帮助文档的 url,设置过后,在 属性检查器 中就会出现一个帮助图标,用户点击将打开指定的网页。

method

help

param
example
const {ccclass, help} = cc._decorator;

 @ccclass
 @help("app://docs/html/components/spine.html")
class NewScript extends cc.Component {
    // ...
}

Private Const icon

icon: any = (DEV ? createEditorDecorator : createDummyDecorator)(checkStringArgument, 'icon')

自定义当前组件在编辑器中显示的图标 url。

method

icon

param
example
const {ccclass, icon} = cc._decorator;

 @ccclass
 @icon("xxxx.png")
class NewScript extends cc.Component {
    // ...
}

Const inspector

inspector: any = (DEV ? createEditorDecorator : createDummyDecorator)(checkStringArgument, 'inspector')

自定义当前组件在 属性检查器 中渲染时所用的网页 url。

method

inspector

param
example
const {ccclass, inspector} = cc._decorator;

 @ccclass
 @inspector("packages://inspector/inspectors/comps/camera-ctrl.js")
class NewScript extends cc.Component {
    // ...
}

Const integer

integer: function = type(CCInteger)

将该属性标记为 cc 整数。

Type declaration

    • (target: Object, propertyKey: string | symbol): void
    • Parameters

      • target: Object
      • propertyKey: string | symbol

      Returns void

Const menu

menu: any = (DEV ? createEditorDecorator : createDummyDecorator)(checkStringArgument, 'menu')

将当前组件添加到组件菜单中,方便用户查找。例如 "Rendering/CameraCtrl"。

method

menu

param

The path is the menu represented like a pathname. For example the menu could be "Rendering/CameraCtrl".

example
const {ccclass, menu} = cc._decorator;

 @ccclass
 @menu("Rendering/CameraCtrl")
class NewScript extends cc.Component {
    // ...
}

Const objectsToDestroy

objectsToDestroy: any = []

Const objsToClearTmpVar

objsToClearTmpVar: any = []

Const playOnFocus

playOnFocus: any = (DEV ? createEditorDecorator : createDummyDecorator)(checkCtorArgument, 'playOnFocus')

当指定了 "executeInEditMode" 以后,playOnFocus 可以在选中当前组件所在的节点时,提高编辑器的场景刷新频率到 60 FPS,否则场景就只会在必要的时候进行重绘。

method

playOnFocus

example
const {ccclass, playOnFocus, executeInEditMode} = cc._decorator;

 @ccclass
 @executeInEditMode
 @playOnFocus
class CameraCtrl extends cc.Component {
    // ...
}

Const prototype

prototype: CCObject = CCObject.prototype

Const requireComponent

requireComponent: any = createEditorDecorator(checkCompArgument, 'requireComponent')

为声明为 CCClass 的组件添加依赖的其它组件。当组件添加到节点上时,如果依赖的组件不存在,引擎将会自动将依赖组件添加到同一个节点,防止脚本出错。该设置在运行时同样有效。

method

requireComponent

param
example
const {ccclass, requireComponent} = cc._decorator;

 @ccclass
 @requireComponent(cc.SpriteComponent)
class SpriteCtrl extends cc.Component {
    // ...
}

Const string

string: function = type(CCString)

将该属性标记为 cc 字符串。

Type declaration

    • (target: Object, propertyKey: string | symbol): void
    • Parameters

      • target: Object
      • propertyKey: string | symbol

      Returns void

Const superCllRegCondition

superCllRegCondition: boolean = /xyz/.test(function () { const xyz = 0; }.toString())

Const tmpArray

tmpArray: never[] = []

Const tmpAttrs

tmpAttrs: never[] = []

Functions

CCClass

  • CCClass(options: any): any
  • 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象

    method

    Class

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

    Parameters

    • options: any

    Returns any

    • the created class

argumentChecker

  • argumentChecker(type: any): function

checkNormalArgument

  • checkNormalArgument(validator_DEV: any, decorate: any, decoratorName: any): (Anonymous function)

dereference

  • dereference(self: any): void

deserializeFireClass

  • deserializeFireClass(self: any, obj: any, serialized: any, klass: any, target: any): void

getAllCtors

  • getAllCtors(baseClass: any, mixins: any, options: any): any[]

validateCtorDEV

  • validateCtorDEV(ctor: any, baseClass: any, className: any, options: any): any

appendProp

  • appendProp(cls: any, name: any): void

boundSuperCalls

  • boundSuperCalls(baseClass: any, options: any, className: any): boolean

checkCtorArgument

  • checkCtorArgument(decorate: any): (Anonymous function)

compile

  • compile(node: any): any

compileDestruct

  • compileDestruct(obj: any, ctor: any): Function

compileObjectTypeJit

  • compileObjectTypeJit(sources: any, defaultValue: any, accessorToSet: any, propNameLiteralToSet: any, assumeHavePropIfIsValue: any, stillUseUrl: any): void
  • Parameters

    • sources: any
    • defaultValue: any
    • accessorToSet: any
    • propNameLiteralToSet: any
    • assumeHavePropIfIsValue: any
    • stillUseUrl: any

    Returns void

compileProps

  • compileProps(this: any, actualClass: any): void

createDummyDecorator

  • createDummyDecorator(argCheckFunc: any): any

createEditorDecorator

  • createEditorDecorator(argCheckFunc: any, editorPropName: any, staticValue?: any): any

declareProperties

  • declareProperties(cls: any, className: any, properties: any, baseClass: any, mixins: any, es6?: undefined | false | true): void
  • Parameters

    • cls: any
    • className: any
    • properties: any
    • baseClass: any
    • mixins: any
    • Optional es6: undefined | false | true

    Returns void

define

  • define(className: any, baseClass: any, mixins: any, options: any): any

defineGetSet

  • defineGetSet(cls: any, name: any, propName: any, val: any, es6: any): void

defineProp

  • defineProp(cls: any, className: any, propName: any, val: any, es6: any): void

deserialize

  • deserialize(data: any, details: any, options: any): any
  • 将 JSON 反序列化为对象实例。

    当指定了 target 选项时,如果 target 引用的其它 asset 的 uuid 不变,则不会改变 target 对 asset 的引用, 也不会将 uuid 保存到 result 对象中。

    method

    deserialize

    Parameters

    • data: any

      the serialized cc.Asset json string or json object.

    • details: any
    • options: any

    Returns any

    the main data(asset)

doDefine

  • doDefine(className: any, baseClass: any, mixins: any, options: any): any

Private doInstantiate

  • doInstantiate(obj: any, parent?: any): any
  • 这是一个通用的 instantiate 方法,可能效率比较低。 之后可以给各种类型重写快速实例化的特殊实现,但应该在单元测试中将结果和这个方法的结果进行对比。 值得注意的是,这个方法不可重入。

    Parameters

    • obj: any

      该方法仅供内部使用,用户需负责保证参数合法。什么参数是合法的请参考 cc.instantiate 的实现。

    • Optional parent: any

    Returns any

enumerateCCClass

  • enumerateCCClass(klass: any, obj: any, clone: any, parent: any): void

enumerateObject

  • enumerateObject(obj: any, clone: any, parent: any): void

equalsToDefault

  • equalsToDefault(def: any, value: any): boolean

escapeForJS

  • escapeForJS(s: any): string

extractActualDefaultValues

  • extractActualDefaultValues(ctor: any): any

fNOP

  • fNOP(ctor: any): any

genProperty

  • genProperty(ctor: any, properties: any, propName: any, options: any, desc: any, cache: any): void

getClassCache

  • getClassCache(ctor: any, decoratorName?: any): any

getDefault

  • getDefault(defaultVal: any): any

getDefaultFromInitializer

  • getDefaultFromInitializer(initializer: any): any

getInheritanceChain

  • getInheritanceChain(constructor: any): any[]

getInitProps

  • getInitProps(attrs: any, propList: any): (Anonymous function)

getInitPropsJit

  • getInitPropsJit(attrs: any, propList: any): any

getNewValueTypeCodeJit

  • getNewValueTypeCodeJit(value: any): string

getPropAccessor

  • getPropAccessor(key: any): string

getSubDict

  • getSubDict(obj: any, key: any): any

instantiate

  • instantiate(original: any, internal_force?: any): any
  • 克隆指定的任意类型的对象,或者从 Prefab 实例化出新节点。

    (Instantiate 时,function 和 dom 等非可序列化对象会直接保留原有引用,Asset 会直接进行浅拷贝,可序列化类型会进行深拷贝。)

    method

    instantiate

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

    Parameters

    • original: any

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

    • Optional internal_force: any

    Returns any

    the newly instantiated object

instantiateObj

  • instantiateObj(obj: any, parent: any): any

isValid

  • isValid(value: any, strictMode?: undefined | false | true): boolean
  • 检查该对象是否不为 null 并且尚未销毁。
    当一个对象的 destroy 调用以后,会在这一帧结束后才真正销毁。
    因此从下一帧开始 isValid 就会返回 false,而当前帧内 isValid 仍然会是 true。
    如果希望判断当前帧是否调用过 destroy,请使用 cc.isValid(obj, true),不过这往往是特殊的业务需求引起的,通常情况下不需要这样。

    method

    isValid

    example
    import * as cc from 'cc';
    var node = new cc.Node();
    cc.log(cc.isValid(node));    // true
    node.destroy();
    cc.log(cc.isValid(node));    // true, still valid in this frame
    // after a frame...
    cc.log(cc.isValid(node));    // false, destroyed in the end of last frame

    Parameters

    • value: any
    • Optional strictMode: undefined | false | true

    Returns boolean

    whether is valid

mergeDeclaration

  • mergeDeclaration(statement: any, expression: any): any

mixinWithInherited

  • mixinWithInherited(dest: any, src: any, filter?: any): void

mixins

  • mixins(...constructors: Function[]): (Anonymous function)

normalizeClassNameDEV

  • normalizeClassNameDEV(className: any): any

parseAttributes

  • parseAttributes(constructor: Function, attributes: IAcceptableAttributes, className: string, propertyName: string, usedInGetter: any): IParsedAttribute[]

property

  • property(options?: IPropertyOptions): PropertyDecorator
  • property(type: PropertyType): PropertyDecorator
  • property(target: Object, propertyKey: string | symbol): void

pushUnique

  • pushUnique(array: any, item: any): void

type

  • type(type: Function): PropertyDecorator
  • type(type: [Function]): PropertyDecorator
  • type<T>(type: PrimitiveType<T>): PropertyDecorator
  • type<T>(type: [PrimitiveType<T>]): PropertyDecorator

unlinkUnusedPrefab

  • unlinkUnusedPrefab(self: any, serialized: any, obj: any): void

writeAssignment

  • writeAssignment(codeArray: any, statement: any, expression: any): void

Object literals

Const DEFAULTMODULECACHE

DEFAULTMODULECACHE: object

cc.Animation

cc.Animation: string = "cc.Animation"

cc.Button

cc.Button: string = "cc.Button"

cc.ClickEvent

cc.ClickEvent: boolean = false

cc.Label

cc.Label: string = "cc.Label"

cc.Node

cc.Node: string = "cc.Node"

cc.PrefabInfo

cc.PrefabInfo: boolean = false

cc.Sprite

cc.Sprite: string = "cc.Sprite"

cc.Widget

cc.Widget: string = "cc.Widget"

Const PrimitiveTypes

PrimitiveTypes: object

Boolean

Boolean: string = "Boolean"

Float

Float: string = "Number"

Integer

Integer: string = "Number"

String

String: string = "String"

Const deferredInitializer

deferredInitializer: object

datas

datas: null = null

init

  • init(): void

push

  • push(data: any): void

Generated using TypeDoc