添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
烦恼的核桃  ·  java ...·  5 月前    · 
八块腹肌的大熊猫  ·  Pytorch ...·  9 月前    · 
活泼的企鹅  ·  Installing Ruby on ...·  1 年前    · 
API Documentation All Packages | All Classes | Index | Frames No Frames
Node
Package laya.display
Class public class Node
Inheritance Node Inheritance EventDispatcher Inheritance Object
Subclasses ComponentNode , Sprite

Node 类是可放在显示列表中的所有对象的基类。该显示列表管理 Laya 运行时中显示的所有对象。使用 Node 类排列显示列表中的显示对象。Node 对象可以有子显示对象。



Public Properties
Property Defined By
destroyed : Boolean
[只读]是否已经销毁。对象销毁后不能再使用。
Node
displayedInStage : Boolean
[read-only] 表示是否在显示列表中显示。
Node
name : String
节点名称。
Node
numChildren : int
[read-only] 子对象数量。
Node
parent : Node
父节点。
Node
timer : Timer
时间控制器,默认为Laya.timer。
Node
Public Methods
Method Defined By
Node 类用于创建节点对象,节点是最基本的元素。
Node
添加子节点。
Node
addChildAt (node: Node , index:int): Node
添加子节点到指定的索引位置。
Node
addChildren (... args):void
批量增加子节点
Node
clearTimer (caller:*, method:Function):void
清理定时器。功能同Laya.timer.clearTimer()。
Node
contains (node: Node ):Boolean
当前容器是否包含指定的 Node 节点对象 。
Node
destroy (destroyChild:Boolean = true):void
销毁此对象。destroy对象默认会把自己从父节点移除,并且清理自身引用关系,等待js自动垃圾回收机制回收。destroy后不能再使用。 destroy时会移除自身的事情监听,自身的timer监听,移除子对象及从父节点移除自己。
Node
销毁所有子对象,不销毁自己本身。
Node
Inherited
event (type:String, data:* = null):Boolean
派发事件。
EventDispatcher
frameLoop (delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void
定时重复执行某函数(基于帧率)。功能同Laya.timer.frameLoop()。
Node
frameOnce (delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void
定时执行一次某函数(基于帧率)。功能同Laya.timer.frameOnce()。
Node
getChildAt (index:int): Node
根据子节点的索引位置,获取子节点对象。
Node
根据子节点的名字,获取子节点对象。
Node
根据子节点对象,获取子节点的索引位置。
Node
Inherited
hasListener (type:String):Boolean
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。
EventDispatcher
Inherited
isMouseEvent (type:String):Boolean
检测指定事件类型是否是鼠标事件。
EventDispatcher
Inherited
off (type:String, caller:*, listener:Function, onceOnly:Boolean = false): EventDispatcher
从 EventDispatcher 对象中删除侦听器。
EventDispatcher
Inherited
offAll (type:String = null): EventDispatcher
从 EventDispatcher 对象中删除指定事件类型的所有侦听器。
EventDispatcher
on (type:String, caller:*, listener:Function, args:Array = null): EventDispatcher
[override] 增加事件侦听器,以使侦听器能够接收事件通知。 如果侦听鼠标事件,则会自动设置自己和父亲节点的属性 mouseEnabled 的值为 true(如果父节点mouseEnabled=false,则停止设置父节点mouseEnabled属性)。
Node
once (type:String, caller:*, listener:Function, args:Array = null): EventDispatcher
[override] 增加事件侦听器,以使侦听器能够接收事件通知,此侦听事件响应一次后则自动移除侦听。 如果侦听鼠标事件,则会自动设置自己和父亲节点的属性 mouseEnabled 的值为 true(如果父节点mouseEnabled=false,则停止设置父节点mouseEnabled属性)。
Node
删除子节点。
Node
根据子节点索引位置,删除对应的子节点对象。
Node
根据子节点名字删除对应的子节点对象,如果找不到不会抛出异常。
Node
removeChildren (beginIndex:int = 0, endIndex:int = 0x7fffffff): Node
删除指定索引区间的所有子对象。
Node
从父容器删除自己,如已经被删除不会抛出异常。
Node
替换子节点。
Node
setChildIndex (node: Node , index:int): Node
设置子节点的索引位置。
Node
timerLoop (delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true, jumpFrame:Boolean = false):void
定时重复执行某函数。功能同Laya.timer.timerLoop()。
Node
timerOnce (delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void
定时执行某函数一次。功能同Laya.timer.timerOnce()。
Node
Events
Event Summary Defined By
添加到父对象后调度。 Node
加入节点树时调度。 Node
被父对象移除后调度。 Node
从节点树移除时调度。 Node
Property Detail
destroyed property
public var destroyed:Boolean

[只读]是否已经销毁。对象销毁后不能再使用。

displayedInStage property
displayedInStage:Boolean [read-only]

表示是否在显示列表中显示。


Implementation
public function get displayedInStage():Boolean
name property
public var name:String

节点名称。

numChildren property
numChildren:int [read-only]

子对象数量。


Implementation
public function get numChildren():int
parent property
parent: Node

父节点。


Implementation
public function get parent(): Node
public function set parent(value: Node ):void
timer property
public var timer: Timer

时间控制器,默认为Laya.timer。

Constructor Detail
Node () Constructor
public function Node()

Node 类用于创建节点对象,节点是最基本的元素。

Method Detail
addChild () method
public function addChild(node: Node ): Node

添加子节点。

Parameters

node : Node — 节点对象

Returns

Node — 返回添加的节点

addChildAt () method
public function addChildAt(node: Node , index:int): Node

添加子节点到指定的索引位置。

Parameters

node : Node — 节点对象。
index :int — 索引位置。

Returns

Node — 返回添加的节点。

addChildren () method
public function addChildren(... args):void

批量增加子节点

Parameters

... args — 无数子节点。
clearTimer () method
public function clearTimer(caller:*, method:Function):void

清理定时器。功能同Laya.timer.clearTimer()。

Parameters

caller :* — 执行域(this)。
method :Function — 结束时的回调方法。
contains () method
public function contains(node: Node ):Boolean

当前容器是否包含指定的 Node 节点对象 。

Parameters

node : Node — 指定的 Node 节点对象 。

Returns

Boolean — 一个布尔值表示是否包含指定的 Node 节点对象 。

destroy () method
public function destroy(destroyChild:Boolean = true):void

销毁此对象。destroy对象默认会把自己从父节点移除,并且清理自身引用关系,等待js自动垃圾回收机制回收。destroy后不能再使用。

destroy时会移除自身的事情监听,自身的timer监听,移除子对象及从父节点移除自己。

Parameters

destroyChild :Boolean (default = true ) — (可选)是否同时销毁子节点,若值为true,则销毁子节点,否则不销毁子节点。
destroyChildren () method
public function destroyChildren():void

销毁所有子对象,不销毁自己本身。

frameLoop () method
public function frameLoop(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void

定时重复执行某函数(基于帧率)。功能同Laya.timer.frameLoop()。

Parameters

delay :int — 间隔几帧(单位为帧)。
caller :* — 执行域(this)。
method :Function — 结束时的回调方法。
args :Array (default = null ) — (可选)回调参数。
coverBefore :Boolean (default = true ) — (可选)是否覆盖之前的延迟执行,默认为true。
frameOnce () method
public function frameOnce(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void

定时执行一次某函数(基于帧率)。功能同Laya.timer.frameOnce()。

Parameters

delay :int — 延迟几帧(单位为帧)。
caller :* — 执行域(this)
method :Function — 结束时的回调方法
args :Array (default = null ) — (可选)回调参数
coverBefore :Boolean (default = true ) — (可选)是否覆盖之前的延迟执行,默认为true
getChildAt () method
public function getChildAt(index:int): Node

根据子节点的索引位置,获取子节点对象。

Parameters

index :int — 索引位置

Returns

Node — 子节点

getChildByName () method
public function getChildByName(name:String): Node

根据子节点的名字,获取子节点对象。

Parameters

name :String — 子节点的名字。

Returns

Node — 节点对象。

getChildIndex () method
public function getChildIndex(node: Node ):int

根据子节点对象,获取子节点的索引位置。

Parameters

node : Node — 子节点。

Returns

int — 子节点所在的索引位置。

on () method
override public function on(type:String, caller:*, listener:Function, args:Array = null): EventDispatcher

增加事件侦听器,以使侦听器能够接收事件通知。

如果侦听鼠标事件,则会自动设置自己和父亲节点的属性 mouseEnabled 的值为 true(如果父节点mouseEnabled=false,则停止设置父节点mouseEnabled属性)。

Parameters

type :String — 事件的类型。
caller :* — 事件侦听函数的执行域。
listener :Function — 事件侦听函数。
args :Array (default = null ) — (可选)事件侦听函数的回调参数。

Returns

EventDispatcher — 此 EventDispatcher 对象。

once () method
override public function once(type:String, caller:*, listener:Function, args:Array = null): EventDispatcher

增加事件侦听器,以使侦听器能够接收事件通知,此侦听事件响应一次后则自动移除侦听。

如果侦听鼠标事件,则会自动设置自己和父亲节点的属性 mouseEnabled 的值为 true(如果父节点mouseEnabled=false,则停止设置父节点mouseEnabled属性)。

Parameters

type :String — 事件的类型。
caller :* — 事件侦听函数的执行域。
listener :Function — 事件侦听函数。
args :Array (default = null ) — (可选)事件侦听函数的回调参数。

Returns

EventDispatcher — 此 EventDispatcher 对象。

removeChild () method
public function removeChild(node: Node ): Node

删除子节点。

Parameters

node : Node — 子节点

Returns

Node — 被删除的节点

removeChildAt () method
public function removeChildAt(index:int): Node

根据子节点索引位置,删除对应的子节点对象。

Parameters

index :int — 节点索引位置。

Returns

Node — 被删除的节点。

removeChildByName () method
public function removeChildByName(name:String): Node

根据子节点名字删除对应的子节点对象,如果找不到不会抛出异常。

Parameters

name :String — 对象名字。

Returns

Node — 查找到的节点( Node )对象。

removeChildren () method
public function removeChildren(beginIndex:int = 0, endIndex:int = 0x7fffffff): Node

删除指定索引区间的所有子对象。

Parameters

beginIndex :int (default = 0 ) — 开始索引。
endIndex :int (default = 0x7fffffff ) — 结束索引。

Returns

Node — 当前节点对象。

removeSelf () method
public function removeSelf(): Node

从父容器删除自己,如已经被删除不会抛出异常。

Returns

Node — 当前节点( Node )对象。

replaceChild () method
public function replaceChild(newNode: Node , oldNode: Node ): Node

替换子节点。

Parameters

newNode : Node — 新节点。
oldNode : Node — 老节点。

Returns

Node — 返回新节点。

setChildIndex () method
public function setChildIndex(node: Node , index:int): Node

设置子节点的索引位置。

Parameters

node : Node — 子节点。
index :int — 新的索引。

Returns

Node — 返回子节点本身。

timerLoop () method
public function timerLoop(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true, jumpFrame:Boolean = false):void

定时重复执行某函数。功能同Laya.timer.timerLoop()。

Parameters

delay :int — 间隔时间(单位毫秒)。
caller :* — 执行域(this)。
method :Function — 结束时的回调方法。
args :Array (default = null ) — (可选)回调参数。
coverBefore :Boolean (default = true ) — (可选)是否覆盖之前的延迟执行,默认为true。
jumpFrame :Boolean (default = false ) — 时钟是否跳帧。基于时间的循环回调,单位时间间隔内,如能执行多次回调,出于性能考虑,引擎默认只执行一次,设置jumpFrame=true后,则回调会连续执行多次
timerOnce () method
public function timerOnce(delay:int, caller:*, method:Function, args:Array = null, coverBefore:Boolean = true):void

定时执行某函数一次。功能同Laya.timer.timerOnce()。

Parameters

delay :int — 延迟时间(单位毫秒)。
caller :* — 执行域(this)。
method :Function — 结束时的回调方法。
args :Array (default = null ) — (可选)回调参数。
coverBefore :Boolean (default = true ) — (可选)是否覆盖之前的延迟执行,默认为true。
Event Detail
added Event
Event Object Type: laya.events.Event
Event.type property = Event.ADDED

添加到父对象后调度。

display Event