小说网站设计模板,苏州企业宣传片制作公司,网上的网站模板怎么下载,建站63年来第一次闭站?北京站辟谣//在Ts、js中 this指向当前的这个组件实例
//this下的一个数据成员node#xff0c;指向组件实例化的这个节点
//同样也可以根据节点找到挂载的所有组件
//this.node 指向当前脚本挂载的节点//子节点与父节点的关系
// Node.parent是一个Node,Node.children是一个Node[]
// th…//在Ts、js中 this指向当前的这个组件实例
//this下的一个数据成员node指向组件实例化的这个节点
//同样也可以根据节点找到挂载的所有组件
//this.node 指向当前脚本挂载的节点//子节点与父节点的关系
// Node.parent是一个Node,Node.children是一个Node[]
// this.node.parent //等同于
console.warn(this.node.parent.name);
// this.node.getParent()
console.warn(this.node.getParent().name);// this.node.children
this.node.children.forEach(element {console.log(子节点)console.log(element.name);
});// 替换父节点 Node.parent /Node.setParent(XX)
this.node.parent this.AddBtn;
console.warn(this.node.parent.name)
// this.node.setParent(value: Node)
this.node.setParent(this.AddBtn);
console.warn(this.node.getParent().name);//添加节点 使用预制的时候property(Node)AddBtn: Node null!;property(Prefab)sprite: Prefab null!;
// addChild(child: Node)
let tempNode: Node instantiate(this.sprite);
// addChild有可能造成内存泄露尤其是加自己玩
this.node.addChild(tempNode);
this.node.children.forEach(element {console.log(子节点);console.warn(element.name);
});
// siblingIndex:设置位置等同于2.x的setIndex(index: number)
// insertChild(child: Node, siblingIndex: number)
this.node.insertChild(tempNode, 0);
this.node.children.forEach(element {console.log(子节点);console.warn(element.name);
});
// getSiblingIndex()
// setSiblingIndex(index: number)//节点查找
find() //从1级节点开始查找
getChildByName(name: string)//下级节点
getChildByPath(path: string)//从下级节点开始算起往下找
// let node find(Canvas/Test);
// console.log(node)
// node this.node.getChildByName(Label)
// node.getComponent(Label).string 哈哈;
// // node this.node.getChildByName(Label)?.getChildByName(Label); //等同于下面这一个行代码
// node this.node.getChildByPath(Label/Label);
// node.getComponent(Label).string ~哈哈~;//节点移除
removeFromParent()
removeChild(child: this | Node)
removeAllChildren()
//节点判断
isChildOf(parent: this | Scene | null)
isValid
// let labelNode this.node.getChildByPath(Label/Label);
// console.log(labelNode.isChildOf(this.node))
// 节点是否销毁
// console.log(this.node.isValid)
//组件查找
//先找节点 再找节点上挂载的组件
// 我测试的结果挂的BoxCollider 查找Collider一样起效果
//根据类型来查找需要引入
getComponentT extends Component
//根据名字来查找不需要引入
getComponent(className: string)
getComponentsT extends Component
getComponents(className: string)
getComponentInChildrenT extends Component
getComponentInChildren(className: string)
getComponentsInChildrenT extends Component
getComponentsInChildren(className: string)
//添加移除组件
addComponentT extends Component
addComponent(className: string)
removeComponentT extends Component
removeComponent(classNameOrInstance: string | Component)
//销毁节点
destroy()
destroyAllChildren()
//事件监听 常用前两
on(type: string | NodeEventType, callback: Function, target?: unknown, useCapture?: boolean)
//this.node.on(Input.EventType.TOUCH_MOVE, this.onTouch, this);
off(type: string | NodeEventType, callback: Function, target?: unknown, useCapture?: boolean)
//this.node.off(Input.EventType.TOUCH_MOVE, this.onTouch, this);
once(type: string | NodeEventType, callback: Function, target?: unknown, useCapture?: boolean)
//通常用非官方分装的EventListener.ts不用这些
emit(type: string, arg0?: any, arg1?: any, arg2?: any, arg3?: any, arg4?: any)
dispatchEvent(event: Event)
hasEventListener(type: string, callback?: Function, target?: unknown)
targetOff(target: unknown)
有时候脑袋一热就问人家怎么样才能简简单单的组件化开发一款游戏怎么样才能合理的把你想要的功能代码化不知道问烦了几个家伙了经常回复我的就是那个节点有要求你就单独挂一个脚本你管它那么多干啥
有时间就学一下3.x就是没3D的素材至于为啥不透露了