This commit is contained in:
2024-08-08 09:10:29 +08:00
parent a4bbdc85a6
commit d06189486d
3 changed files with 13 additions and 13 deletions

View File

@@ -62,7 +62,7 @@ export class SingletonModuleComp extends ecs.Comp {
}; };
vmAdd() { vmAdd() {
console.log("dataModelComp vmAdd"); console.log("smc vm_data vmAdd");
VM.add(this.vm_data, "data"); VM.add(this.vm_data, "data");
} }
reset() { reset() {

View File

@@ -8,11 +8,11 @@
/** 碰撞分组 */ /** 碰撞分组 */
export enum BoxSet { export enum BoxSet {
//物理碰撞tag //物理碰撞tag
DEFAULT = 0, DEFAULT = 1,
MONSTER = 90, MONSTER = 2,
HERO = 10, HERO = 4,
MONSTER_SKILL = 91, MONSTER_SKILL = 8,
HERO_SKILL = 11, HERO_SKILL = 16,
BOX_WIDTH = 64, BOX_WIDTH = 64,
BOX_HEIGHT = 64, BOX_HEIGHT = 64,

View File

@@ -52,9 +52,9 @@ export class MonsterViewComp extends CCComp {
} }
} }
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) { onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
switch (selfCollider.tag) { switch (selfCollider.group) {
case BoxSet.MONSTER: case BoxSet.MONSTER:
switch (otherCollider.tag){ switch (otherCollider.group){
case BoxSet.HERO: case BoxSet.HERO:
this.state = 2; this.state = 2;
console.log('onBeginContact',selfCollider,otherCollider); console.log('onBeginContact',selfCollider,otherCollider);
@@ -70,7 +70,7 @@ export class MonsterViewComp extends CCComp {
} }
break; break;
case BoxSet.HERO: case BoxSet.HERO:
switch (otherCollider.tag){ switch (otherCollider.group){
case BoxSet.MONSTER: case BoxSet.MONSTER:
this.state = 2; this.state = 2;
break; break;
@@ -90,8 +90,8 @@ export class MonsterViewComp extends CCComp {
// console.log('onPreSolve'); // console.log('onPreSolve');
// } // }
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) { onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
if (otherCollider.tag === BoxSet.HERO && selfCollider.tag === BoxSet.MONSTER) { if (otherCollider.group === BoxSet.HERO && selfCollider.group === BoxSet.MONSTER) {
// console.log('onPostSolve otherCollider.tag :'+otherCollider.tag); // console.log('onPostSolve otherCollider.group :'+otherCollider.group);
// this.speed = 0; // this.speed = 0;
// this.timer = 1; // this.timer = 1;
} }
@@ -114,9 +114,9 @@ export class MonsterViewComp extends CCComp {
label.getComponent(Label)!.string = hero_name; label.getComponent(Label)!.string = hero_name;
let collider = this.getComponent(Collider2D); let collider = this.getComponent(Collider2D);
if(camp==1){ if(camp==1){
collider.tag=BoxSet.HERO; collider.group=BoxSet.HERO;
}else{ }else{
collider.tag=BoxSet.MONSTER; collider.group=BoxSet.MONSTER;
} }
} }