Constructors
constructor
Properties
data
data: any = undefined
id
id: number = -1
Accessors
destroyed
Returns boolean
enabled
- get enabled(): boolean
- set enabled(value: boolean): void
Returns boolean
Parameters
Returns void
globalEnabled
- get globalEnabled(): boolean
Returns boolean
isInScene
Returns boolean
name
- get name(): string
- set name(value: string): void
Returns string
Parameters
Returns void
numChildren
- get numChildren(): number
Returns number
parent
- get parent(): undefined | Node
Returns undefined | Node
root
- get root(): undefined | IAnimation
Returns undefined | IAnimation
scene
- get scene(): undefined | Scene
Returns undefined | Scene
visible
- get visible(): boolean
- set visible(value: boolean): void
Returns boolean
Parameters
Returns void
Methods
addChild
Parameters
addChildAt
- addChildAt(node: Node, index: number): Node
Parameters
addScript
Parameters
Returns undefined | Script
contains
- contains(target: Node): boolean
Parameters
Returns boolean
destroy
Returns void
destroyChildren
Returns void
destroyScripts
- destroyScripts(scriptClass?: typeof Script): void
Parameters
Optional scriptClass: typeof Script
Returns void
emit
- emit(type: string, data?: unknown[]): void
Parameters
type: string
Optional data: unknown[]
Returns void
fromJson
- fromJson(json: INodeData): Promise<void>
Parameters
Returns Promise<void>
getById
- getById(id: number): undefined | Node
Parameters
Returns undefined | Node
getChildAt
- getChildAt(index: number): Node
Parameters
getChildByName
- getChildByName(name: string, deep?: boolean): undefined | Node
Parameters
name: string
deep: boolean = false
Returns undefined | Node
getChildIndex
- getChildIndex(node: Node): number
Parameters
Returns number
getScript
- getScript<T>(ScriptClass?: T, deep?: boolean): undefined | InstanceType<T>
Type parameters
T: new (...args: any[]) => Script
Parameters
ScriptClass: T = ...
deep: boolean = false
Returns undefined | InstanceType<T>
getScriptByName
- getScriptByName(name: string): undefined | Script
Parameters
Returns undefined | Script
getScripts
- getScripts<T>(ScriptClass?: T, deep?: boolean): InstanceType<T>[]
Type parameters
T: new (...args: any[]) => Script
Parameters
ScriptClass: T = ...
deep: boolean = false
Returns InstanceType<T>[]
load
- load(url: string): Promise<void>
Parameters
Returns Promise<void>
off
- off(type: string, listener: (...args: any[]) => void, caller?: unknown): void
Parameters
type: string
listener: (...args: any[]) => void
Optional caller: unknown
Returns void
offAll
- offAll(caller?: unknown): void
Parameters
Returns void
on
- on<A>(type: "click" | "mouseup" | "mousedown" | "mousemove" | "loaded" | "ended" | "enabled" | "textChanged", listener: A, caller?: unknown, args?: Parameters<A>): void
- on<A>(type: string, listener: A, caller?: unknown, args?: Parameters<A>): void
Type parameters
A: (...args: any[]) => void
Parameters
type: "click" | "mouseup" | "mousedown" | "mousemove" | "loaded" | "ended" | "enabled" | "textChanged"
listener: A
Optional caller: unknown
Optional args: Parameters<A>
Returns void
Type parameters
A: (...args: any[]) => void
Parameters
type: string
listener: A
Optional caller: unknown
Optional args: Parameters<A>
Returns void
once
- once<A>(type: string, listener: A, caller?: unknown, args?: Parameters<A>): void
Type parameters
A: (...args: any[]) => void
Parameters
type: string
listener: A
Optional caller: unknown
Optional args: Parameters<A>
Returns void
removeChild
Parameters
removeChildAt
- removeChildAt(index: number): Node
Parameters
removeChildByName
- removeChildByName(name: string): Node
Parameters
removeChildren
Returns void
removeSelf
setChildIndex
- setChildIndex(node: Node, index: number): Node
Parameters
setProp
- setProp(prop: string, value: unknown): void
Parameters
prop: string
value: unknown
Returns void
抽象节点,负责节点管理,事件监听,及加载解析
Node 是 2D 和 3D 节点的基类
可监听的事件:enabled