Ts:
this--当前脚本
this.node等--当前脚本的组件
start(){}--只在开始时执行一次
update(){}--逐帧执行
delatTime--1/刷新率(帧数)
p.x += 100* deltaTime;//统一设备之间的效果,帧同步
控制台输出:
console.log("") ;
获取节点:
const label = this.node.getComponent(Label);
label.string = '111';
位移:
this.node.setPosition(0,0);
穿三个为三维向量,两个为二维向量
const pos = new Vec2(0,0);
this.node.setPosition(pos);
--尽量使用复用变量,优化性能
setPosition()的方法有有out参数,如果为空新建一个变量,导致垃圾冗余
--改变时需要使用标识存放数据来表明数据改变(使用position的属性寄存器)
const currentP = new Vec3();
this.node.getPosition(currentP );
currentP .x += 300;
this.node.setPosition(currentP );
旋转:
this.node.angle(1);