技能动画添加
This commit is contained in:
@@ -4,29 +4,17 @@ const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('LineCom')
|
||||
export class LineCom extends Component {
|
||||
base:SkillCom = null
|
||||
start() {
|
||||
let base =this.node.getComponent(SkillCom)
|
||||
let time = 720 / base.speed;
|
||||
let squaredDistance = base.t_pos.x * base.t_pos.x + base.t_pos.y * base.t_pos.y;
|
||||
let distance = Math.sqrt(squaredDistance);
|
||||
time = distance / base.speed;
|
||||
let e_pos=v3(this.node.position.x+base.t_pos.x,this.node.position.y+base.t_pos.y)
|
||||
// console.log("skill tx:"+e_pos.x+" node :"+this.node.position.x)
|
||||
this.node.getChildByName("skill").setRotationFromEuler(0,0,base.angle)
|
||||
// console.log("skill ",this.node.getRotation())
|
||||
tween(this.node).to( time,{ position: e_pos},
|
||||
{
|
||||
easing: "linear",
|
||||
onUpdate: (target: Vec3, ratio: number) => { },
|
||||
onComplete: (target?: object) => {
|
||||
base.is_destroy=true
|
||||
},
|
||||
}
|
||||
).start();
|
||||
this.base =this.node.getComponent(SkillCom)
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
this.node.setPosition(this.node.position.x+this.base.speed*deltaTime,this.node.position.y,this.node.position.z)
|
||||
if(this.node.position.x>1000||this.node.position.x<-1000){
|
||||
this.base.is_destroy = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user