import { _decorator, Component, EventKeyboard, Input, input, KeyCode, Node, Vec3 } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('n4')
export class n4 extends Component {
z1:number = 0
start() {
input.on(Input.EventType.KEY_DOWN, this.onKeyDown, this)
input.on(Input.EventType.KEY_UP, this.onKeyUp, this)
}
onKeyDown(event: EventKeyboard){
if (event.keyCode == KeyCode.KEY_W){
this.z1 = -0.01
}
}
onKeyUp(event: EventKeyboard){
if (event.keyCode == KeyCode.KEY_W){
this.z1 = 0
}
let b1 = this.node.worldPosition
let b2 = this.node.position
let b3 = this.node.parent.worldPosition
let b4 = this.node.parent.position
console.log(b1 + 'sss')
console.log(b2 + 'ddd')
console.log(b3 + 'sss')
console.log(b4 + 'ddd')
this.node.parent.setPosition(b1)
this.node.setPosition(0,0,0)
let b5 = this.node.worldPosition
let b6 = this.node.position
let b7 = this.node.parent.worldPosition
let b8 = this.node.parent.position
console.log(b5 + 'www')
console.log(b6 + 'eee')
console.log(b7 + 'www')
console.log(b8 + 'eee')
}
update(deltaTime: number) {
let a1 = this.node.position
this.node.setPosition(a1.x,a1.y,a1.z+this.z1)
}
}