dd
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
* @LastEditTime: 2022-08-17 12:36:18
|
||||
*/
|
||||
|
||||
import { Vec3, _decorator ,tween} from "cc";
|
||||
import { Vec3, _decorator ,Collider2D,Contact2DType,PhysicsSystem2D,IPhysics2DContact} 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";
|
||||
|
||||
import {BoxSet} from "../common/config/BoxSet"
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 角色显示组件 */
|
||||
@@ -20,6 +20,38 @@ export class HeroViewComp extends CCComp {
|
||||
as: HeroSpine = null!;
|
||||
/** 角色控制器 */
|
||||
|
||||
|
||||
start () {
|
||||
// 注册单个碰撞体的回调函数
|
||||
// console.log('MonsterViewComp start');
|
||||
let collider = this.getComponent(Collider2D);
|
||||
// console.log('hero collider',collider);
|
||||
if (collider) {
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
|
||||
// 注册全局碰撞回调函数
|
||||
if (PhysicsSystem2D.instance) {
|
||||
// console.log('PhysicsSystem2D.instance');
|
||||
PhysicsSystem2D.instance.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
}
|
||||
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
||||
// 只在两个碰撞体开始接触时被调用一次
|
||||
// console.log('hero Contact,selfCollider',selfCollider);
|
||||
switch (otherCollider.group) {
|
||||
case BoxSet.MONSTER:
|
||||
console.log('hero coolider MONSTER ');
|
||||
break;
|
||||
case BoxSet.MONSTER_SKILL:
|
||||
console.log('hero coolider MONSTER skill');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
this.as = this.getComponent(HeroSpine);
|
||||
|
||||
Reference in New Issue
Block a user