重新 使用碰撞来处理 抛射型技能逻辑处理
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math, clamp, Game, tween, Color} from "cc";
|
||||
import { Vec3, _decorator , v3,Collider2D,Contact2DType,Label ,Node,Prefab,instantiate,ProgressBar, Component, Material, Sprite, math, clamp, Game, tween, Color, RigidBody, RigidBody2D} 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 { HeroSpine } from "./HeroSpine";
|
||||
@@ -24,7 +24,6 @@ export class HeroViewComp extends CCComp {
|
||||
BUFFCOMP:BuffComp=null!
|
||||
enemy_pos:Vec3=null!
|
||||
// enemy:any=null!;
|
||||
|
||||
as: HeroSpine = null!
|
||||
anm_timer:Timer = new Timer(0.3);
|
||||
anm_name="idle"
|
||||
@@ -37,9 +36,10 @@ export class HeroViewComp extends CCComp {
|
||||
scale: number = 1; /** 角色阵营 1:hero -1 :mon */
|
||||
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
|
||||
fac:number=0; //阵营 0:hero 1:monster
|
||||
box_group:number = BoxSet.HERO;
|
||||
atk_range:number = 150;
|
||||
|
||||
box_group:number = BoxSet.HERO;
|
||||
rigid:RigidBody2D=null!;
|
||||
|
||||
|
||||
is_dead:boolean = false; //是否摧毁
|
||||
@@ -120,8 +120,39 @@ export class HeroViewComp extends CCComp {
|
||||
|
||||
onLoad() {
|
||||
this.as = this.getComponent(HeroSpine);
|
||||
// 注册单个碰撞体的回调函数
|
||||
|
||||
} /** 视图层逻辑代码分离演示 */
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = this.box_group;
|
||||
// console.log("hero collider ",this.scale,collider);
|
||||
if (collider) {
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
||||
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
|
||||
// collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||
}
|
||||
this.rigid = this.getComponent(RigidBody2D);
|
||||
if(this.rigid.sleep){
|
||||
console.log("hero rigid sleep ",this.scale,this.rigid);
|
||||
this.rigid.wakeUp();
|
||||
}
|
||||
}
|
||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
console.log("碰撞开始 ",this.scale,seCol,oCol);
|
||||
}
|
||||
|
||||
onEndContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
console.log("碰撞结束 ",this.scale,seCol,oCol);
|
||||
}
|
||||
onPreSolve (seCol: Collider2D, oCol: Collider2D) {
|
||||
console.log("碰撞预处理 ",this.scale,seCol,oCol);
|
||||
}
|
||||
|
||||
onPostSolve (seCol: Collider2D, oCol: Collider2D) {
|
||||
console.log("碰撞后处理 ",this.scale,seCol,oCol);
|
||||
}
|
||||
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start () {
|
||||
this.as.idle()
|
||||
this.BUFFCOMP=this.node.getComponent(BuffComp);
|
||||
|
||||
Reference in New Issue
Block a user