添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • string String 输入框的初始输入内容,如果为空则会显示占位符的文本。
  • backgroundImage SpriteFrame 输入框的背景图片
  • returnType EditBox.KeyboardReturnType 指定移动设备上面回车按钮的样式。
  • inputFlag EditBox.InputFlag 指定输入标志位,可以指定输入方式为密码或者单词首字母大写。
  • inputMode EditBox.InputMode 指定输入模式: ANY表示多行输入,其它都是单行输入,移动平台上还可以指定键盘样式。
  • fontSize Number 输入框文本的字体大小
  • lineHeight Number 输入框文本的行高。
  • fontColor Color 输入框文本的颜色。
  • placeholder String 输入框占位符的文本内容。
  • placeholderFontSize Number 输入框占位符的字体大小。
  • placeholderFontColor Color 输入框占位符的字体颜色。
  • maxLength Number 输入框最大允许输入的字符个数。
  • stayOnTop Boolean
  • tabIndex Number 修改 DOM 输入元素的 tabIndex,这个属性只有在 Web 上面修改有意义。
  • editingDidBegan Component.EventHandler[] 开始编辑文本输入框触发的事件回调。
  • textChanged Component.EventHandler[] 编辑文本输入框时触发的事件回调。
  • editingDidEnded Component.EventHandler[] 结束编辑文本输入框时触发的事件回调。
  • editingReturn Component.EventHandler[] 当用户按下回车按键时的事件回调,目前不支持 windows 平台
  • _sgNode _ccsg.Node Reference to the instance of _ccsg.Node
  • __eventTargets Array Register all related EventTargets,...
  • node Node 该组件被附加到的节点。
  • uuid String 组件的 uuid,用于编辑器。
  • _enabled Boolean
  • enabled Boolean 表示该组件自身是否启用。
  • enabledInHierarchy Boolean 表示该组件是否被启用并且所在的节点也处于激活状态。
  • _isOnLoadCalled Number 返回一个值用来判断 onLoad 是否被调用过,不等于 0 时调用过,等于 0 时未调用。
  • _name String
  • _objFlags Number
  • name String 该对象的名称。
  • isValid Boolean 表示该对象是否可用(被 destroy 后将不可用)。
  • setFocus 让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效...
  • isFocused 判断 EditBox 是否获得了焦点...
  • destroy 如果你不再使用 EditBox,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
  • _createSgNode Create and returns your new scene graph node (SGNode) to add to scene graph....
  • _initSgNode
  • _removeSgNode
  • update 如果该组件启用,则每帧调用 update。
  • lateUpdate 如果该组件启用,则每帧调用 LateUpdate。
  • __preload __preload is called before every onLoad....
  • onLoad 当附加到一个激活的节点上或者其节点第一次激活时候调用。
  • start 如果该组件第一次启用,则在所有组件的 update 之前调用。
  • onEnable 当该组件被启用,并且它的节点也激活时。
  • onDisable 当该组件被禁用或节点变为无效时调用。
  • onDestroy 当该组件被销毁时调用
  • onFocusInEditor
  • onLostFocusInEditor
  • resetInEditor 用来初始化组件或节点的一些属性,当该组件被第一次添加到节点上或用户点击了它的 Reset 菜单时调用。
  • addComponent 向节点添加一个组件类,你还可以通过传入脚本的名称来添加组件。
  • getComponent 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
  • getComponents 返回节点上指定类型的所有组件。
  • getComponentInChildren 递归查找所有子节点中第一个匹配指定类型的组件。
  • getComponentsInChildren 递归查找自身或所有子节点中指定类型的组件
  • _getLocalBounds 以便编辑器的场景视图可以正确地执行点选测试。
  • onRestore onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
  • schedule 调度一个自定义的回调函数。
  • scheduleOnce 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。
  • unschedule 取消调度一个自定义的回调函数。
  • unscheduleAllCallbacks 取消调度所有已调度的回调函数:定制的回调函数以及 'update' 回调函数。
  • _destruct Clear all references in the instance....
  • _onPreDestroy Called before the object being destroyed.
  • _serialize The customized serialization for this object. (Editor Only)
  • _deserialize Init this object from the custom serialized data.
  • editing-did-began 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
  • editing-did-ended 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
  • text-changed 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
  • editing-return 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
  • Details

    属性(properties)

    string

    输入框的初始输入内容,如果为空则会显示占位符的文本。

    Reference to the instance of _ccsg.Node If it is possible to return null from your overloaded _createSgNode, then you should always check for null before using this property and reimplement __preload .

    cc.log(node.isValid); // true node.destroy(); cc.log(node.isValid); // true, still valid in this frame // after a frame... cc.log(node.isValid); // false, destroyed in the end of last frame
    setFocus

    让当前 EditBox 获得焦点,只有在 stayOnTop 为 true 的时候设置有效 Note: only available on Web at the moment.

    description
    editbox.node.parent = null;  // or  editbox.node.removeFromParent(false);
    // when you don't need editbox anymore
    editbox.node.destroy();
    
    _createSgNode

    Create and returns your new scene graph node (SGNode) to add to scene graph. You should call the setContentSize of the SGNode if its size should be the same with the node's.

    description
    __preload

    __preload is called before every onLoad. It is used to initialize the builtin components internally, to avoid checking whether onLoad is called before every public method calls. This method should be removed if script priority is supported.

    description
  • typeOrClassName Function | String the constructor or the class name of the component to add
  • var sprite = node.addComponent(cc.Sprite);
    var test = node.addComponent("Test");
    
    getComponent

    获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
    传入参数也可以是脚本的名称。

    description
    // get sprite component.
    var sprite = node.getComponent(cc.Sprite);
    // get custom test calss.
    var test = node.getComponent("Test");
    
    getComponents

    返回节点上指定类型的所有组件。

    description
    var sprite = node.getComponentInChildren(cc.Sprite);
    var Test = node.getComponentInChildren("Test");
    
    getComponentsInChildren

    递归查找自身或所有子节点中指定类型的组件

    description
    var sprites = node.getComponentsInChildren(cc.Sprite);
    var tests = node.getComponentsInChildren("Test");
    
    _getLocalBounds

    如果组件的包围盒与节点不同,您可以实现该方法以提供自定义的轴向对齐的包围盒(AABB), 以便编辑器的场景视图可以正确地执行点选测试。

    description

    onRestore 是用户在检查器菜单点击 Reset 时,对此组件执行撤消操作后调用的。
    如果组件包含了“内部状态”(不在 CCClass 属性中定义的临时成员变量),那么你可能需要实现该方法。
    编辑器执行撤销/重做操作时,将调用组件的 get set 来录制和还原组件的状态。 然而,在极端的情况下,它可能无法良好运作。
    那么你就应该实现这个方法,手动根据组件的属性同步“内部状态”。 一旦你实现这个方法,当用户撤销或重做时,组件的所有 get set 都不会再被调用。 这意味着仅仅指定了默认值的属性将被编辑器记录和还原。
    同样的,编辑可能无法在极端情况下正确地重置您的组件。
    于是如果你需要支持组件重置菜单,你需要在该方法中手工同步组件属性到“内部状态”。
    一旦你实现这个方法,组件的所有 get set 都不会在重置操作时被调用。 这意味着仅仅指定了默认值的属性将被编辑器重置。 此方法仅在编辑器下会被调用。

    description
  • callback function The callback function
  • interval Number Tick interval in seconds. 0 means tick every frame.
  • repeat Number The selector will be executed (repeat + 1) times, you can use cc.macro.REPEAT_FOREVER for tick infinitely.
  • delay Number The amount of time that the first tick will wait before execution.
  • var timeCallback = function (dt) {
      cc.log("time: " + dt);
    this.schedule(timeCallback, 1);
    
    scheduleOnce

    调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。

    description
  • callback function A function wrapped as a selector
  • delay Number The amount of time that the first tick will wait before execution.
  • var timeCallback = function (dt) {
      cc.log("time: " + dt);
    this.scheduleOnce(timeCallback, 2);
    
    unschedule

    取消调度一个自定义的回调函数。

    description
    _destruct

    Clear all references in the instance.

    NOTE: this method will not clear the getter or setter functions which defined in the instance of CCObject. You can override the _destruct method if you need, for example: _destruct: function () { for (var key in this) { if (this.hasOwnProperty(key)) { switch (typeof this[key]) { case 'string': this[key] = ''; break; case 'object': case 'function': this[key] = null; break; description