From 288ba1c40aa7ca6c498b636a88819625a1ac78f5 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Tue, 1 Mar 2016 22:28:36 +0800 Subject: [PATCH] complete api syntax for CCClass options --- cocos2d/core/components/CCComponent.js | 69 ------------------------ cocos2d/core/platform/CCClass.js | 75 +++++++++++++++++++++++++- cocos2d/core/value-types/CCVec2.js | 7 +-- 3 files changed, 75 insertions(+), 76 deletions(-) diff --git a/cocos2d/core/components/CCComponent.js b/cocos2d/core/components/CCComponent.js index 8046f2204a..183d1c191c 100644 --- a/cocos2d/core/components/CCComponent.js +++ b/cocos2d/core/components/CCComponent.js @@ -744,86 +744,19 @@ var Component = cc.Class({ }, }); -/** - * Automatically add required component as a dependency. - * - * @property _requireComponent - * @type {Function} - * @default null - * @static - * @readonly - * @private - */ Component._requireComponent = null; if (CC_DEV) { // INHERITABLE STATIC MEMBERS - /** - * 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. - * - * @property _executeInEditMode - * @type {Boolean} - * @default false - * @static - * @readonly - * @private - */ Component._executeInEditMode = false; - - /** - * 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. - * - * @property _playOnFocus - * @type {Boolean} - * @default false - * @static - * @readonly - * @private - */ Component._playOnFocus = false; - - /** - * If specified to a type, prevents Component of the same type (or subtype) to be added more than once to a Node. - * - * @property _disallowMultiple - * @type {Function} - * @default null - * @static - * @readonly - * @private - */ Component._disallowMultiple = null; // NON-INHERITED STATIC MEMBERS - /** - * Specifying the url of the custom html to draw the component in inspector. - * - * @property _inspector - * @type {String} - * @default "" - * @static - * @readonly - * @private - */ Object.defineProperty(Component, '_inspector', { value: '', enumerable: false }); - - /** - * Specifying the url of the icon to display in inspector. - * - * @property _icon - * @type {String} - * @default "" - * @static - * @readonly - * @private - */ Object.defineProperty(Component, '_icon', { value: '', enumerable: false }); // COMPONENT HELPERS @@ -876,8 +809,6 @@ Object.defineProperty(Component, '_registerEditorProps', { Object.defineProperty(cls, '_icon', { value: val }); break; - // {String} menu - // The menu path to register a component to the editors "Component" menu. Eg. "Rendering/Camera" case 'menu': Component._addMenuItem(cls, val, props.menuPriority); break; diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index fa552ad530..299ecbe084 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -658,12 +658,83 @@ function declareProperties (cls, className, properties, baseClass, mixins) { } } +/** + * @class _ComponentAttributes + * @constructor + */ +/** + * Automatically add required component as a dependency. + * + * @property requireComponent + * @type {Component} + * @default null + */ +/** + * If specified to a type, prevents Component of the same type (or subtype) to be added more than once to a Node. + * + * @property disallowMultiple + * @type {Component} + * @default null + */ +/** + * The menu path to register a component to the editors "Component" menu. Eg. "Rendering/Camera". + * + * @property menu + * @type {String} + * @default "" + */ +/** + * 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. + * + * @property executeInEditMode + * @type {Boolean} + * @default false + */ +/** + * 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. + * + * @property playOnFocus + * @type {Boolean} + * @default false + */ +/** + * Specifying the url of the custom html to draw the component in inspector. + * + * @property inspector + * @type {String} + * @default "" + */ +/** + * Specifying the url of the icon to display in inspector. + * + * @property icon + * @type {String} + * @default "" + */ + +/** + * @module cc + */ + /** * !#en Defines a CCClass using the given specification, please see [Class](/en/scripting/class/) for details. * !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/zh/scripting/class/)。 - * + * * @method Class - * @param {Object} options + * + * @param {Object} [options] + * @param {String} [options.name] - The class name used for serialization. + * @param {Function} [options.extends] - The base class. + * @param {Function} [options.ctor] - The constructor. + * @param {Object} [options.properties] - The property definitions. + * @param {Object} [options.editor] - The attributes for Component, see {{#crossLink "_ComponentAttributes"}}ComponentAttributes{{/crossLink}}. + * @param {Object} [options.statics] - The static members. + * @param {Function[]} [options.mixins] + * * @return {Function} - the created class * * @example diff --git a/cocos2d/core/value-types/CCVec2.js b/cocos2d/core/value-types/CCVec2.js index a734dddd22..175d650121 100644 --- a/cocos2d/core/value-types/CCVec2.js +++ b/cocos2d/core/value-types/CCVec2.js @@ -30,7 +30,6 @@ var FireClass = require('../platform/CCClass'); /** * Representation of 2D vectors and points. * - * see {{#crossLink Vec2 }}cc.Vec2{{/crossLink}} * @class Vec2 * @extends ValueType * @constructor @@ -470,14 +469,12 @@ JS.get(Vec2, 'RIGHT', function () { cc.Vec2 = Vec2; /** - * * @module cc - * */ /** - * The convenience method to create a new {{#crossLink Vec2/Vec2 }}{{/crossLink}} + * The convenience method to create a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. * @method v2 * @param {Number|Object} [x=0] * @param {Number} [y=0] @@ -488,7 +485,7 @@ cc.v2 = function v2 (x, y) { }; /** - * Helper function that creates a cc.Vec2. + * The convenience method to creates a new {{#crossLink "Vec2"}}cc.Vec2{{/crossLink}}. * @method p * @param {Number|Object} [x=0] a Number or a size object * @param {Number} [y=0]