技能移动修改
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact} from "cc";
|
||||
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween} from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
@@ -16,9 +16,10 @@ export class SkillCom extends CCComp {
|
||||
// // this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
// }
|
||||
speed:number = 200;
|
||||
range:number = 80;
|
||||
dis:number = 80;
|
||||
scale:number = 1;
|
||||
atk:number = 10;
|
||||
t_pos:Vec3 = null;
|
||||
is_destroy:boolean = false;
|
||||
start() {
|
||||
this.node.active=true
|
||||
@@ -27,6 +28,19 @@ export class SkillCom extends CCComp {
|
||||
// collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||
}
|
||||
if(this.t_pos){
|
||||
tween(this.node).to( 0.5,{ position: new Vec3(0, 10, 0) } ).start();
|
||||
}else{
|
||||
tween(this.node).to( this.dis/this.speed,
|
||||
{ position: new Vec3(this.node.position.x+this.scale*this.dis,this.node.position.y) },
|
||||
{
|
||||
onComplete: (target?: object) => {
|
||||
this.toDestroy()
|
||||
},
|
||||
}
|
||||
).start();
|
||||
}
|
||||
|
||||
}
|
||||
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
switch (selfCollider.group) {
|
||||
@@ -67,9 +81,9 @@ export class SkillCom extends CCComp {
|
||||
collider.group = group;
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
||||
this.node.setPosition(v3(this.node.position.x+deltaTime*this.speed*this.scale,this.node.position.y,this.node.position.z))
|
||||
if(Math.abs(this.node.position.x) > this.range)
|
||||
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
||||
this.move(deltaTime)
|
||||
if(Math.abs(this.node.position.x) > this.dis)
|
||||
{
|
||||
if(this.is_destroy){
|
||||
return
|
||||
@@ -81,6 +95,11 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
|
||||
}
|
||||
move(dt: number) {
|
||||
// this.node.setPosition(v3(this.node.position.x+dt*this.speed*this.scale,this.node.position.y,this.node.position.z))
|
||||
}
|
||||
|
||||
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
|
||||
Reference in New Issue
Block a user