input.on(Input.EventType.KEY_DOWN,this.method,this)
method(event:EventKeyboard){
switch(event.keyCode){
case KeyCode.SPACE:
console.log("被按下了")
}
}
input.on(Input.EventType.KEY_DOWN,this.method,this)
method(event:EventKeyboard){
switch(event.keyCode){
case KeyCode.SPACE:
console.log("被按下了")
}
}
dir
@property(Prefab)
@property({type:Prefab})
pr:Prefab=null
if(this.pr){
let newNode=instantiate(this.pr)
this.node.addChild(newNode)
newNode.setPosition(100,100)
}else{
console.log("请设置预制体:)
}
let newPosition = this.node.getPosition().add3f(100*deltaTime,0,0)
this.node.setPosition(newPosition)
conts v1 = new Vec2(1,0)
const v2 = new Vec2(0,50)
v1.add(v2)
v1.subtract(v2)
v1.multiplyScalar(3)
v1.dot(v2)
v1.length()
v1.normalize()
const = worldPosition
=this.node.getWordPosition;
this.node.setWorldPosition(300,40);
this.node.setPosition(100,200)
this.node.setRotationFromEuler(0,0,45)
this.node.setScale(2,2)
let newNode = new Node("newnode")
this.node.addChild(newNode)
directior.getScene().addChild(newNode)
newNode.setParent(this.node)
this.node.getChildByName("newNode")
find("Canvas/bird").name
this.node.removeAllChildren()
this.node.destroy()
课程真鸡巴水
implements,类似映射
director.addPersistRootNode(this.node);
切换场景不会消失
//本地坐标转换为世界坐标
let worldPos = this.node.getComponent(UITransform).convertToWorldSpaceAR(this.node.getPosition()):
console.log(worldPos);
//世界坐标转换为本地坐标
let localPos = this.node.getComponent(UITransform).convertToNodeSpaceAR(worldPos)
console.log(localPos):
this.node.setRotationFromEuler(0,0,90);
二维角度
监视功能
SET和GET的方法