From 68c4d94ccce248670810e56bb9a6ce72177694a6 Mon Sep 17 00:00:00 2001 From: panw Date: Mon, 21 Jul 2025 16:51:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20=E9=A2=84=E5=88=B6?= =?UTF-8?q?=E4=BD=93=E5=88=9A=E7=94=9F=E6=88=90=E8=BF=98=E6=B2=A1=E7=A7=BB?= =?UTF-8?q?=E5=88=B0=E5=87=BA=E7=94=9F=E7=82=B9=E5=B0=B1=E5=8F=91=E7=94=9F?= =?UTF-8?q?=E7=A2=B0=E6=92=9E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/Main.ts | 6 +++++- assets/script/game/hero/HeroViewComp.ts | 6 +++++- assets/script/game/hero/Mon.ts | 5 +++-- assets/script/game/skills/SkillCom.ts | 5 +++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/assets/script/Main.ts b/assets/script/Main.ts index e2ecf0ed..b582c586 100644 --- a/assets/script/Main.ts +++ b/assets/script/Main.ts @@ -14,7 +14,11 @@ const { ccclass, property } = _decorator; @ccclass('Main') export class Main extends Root { start() { - // PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb + // PhysicsSystem2D.instance.debugDrawFlags = EPhysics2DDrawFlags.Aabb | + // EPhysics2DDrawFlags.Pair | + // EPhysics2DDrawFlags.CenterOfMass | + // EPhysics2DDrawFlags.Joint | + // EPhysics2DDrawFlags.Shape; } protected async run() { smc.initialize = ecs.getEntity(Initialize); diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index e930ccfe..17b522dc 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -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, BoxCollider2D} 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"; @@ -121,6 +121,10 @@ export class HeroViewComp extends CCComp { this.on(GameEvent.UpdateHP,this.update_hp,this) this.on(GameEvent.EXPUP,this.exp_up,this) this.on(GameEvent.UseEnhancement,this.use_enhancement,this) + const collider = this.node.getComponent(BoxCollider2D); + this.scheduleOnce(()=>{ + if (collider) collider.enabled = true; // 先禁用 + },2) // let anm = this.node.getChildByName("anm") // anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8); } diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index 37fd6663..062280e5 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -1,4 +1,4 @@ -import { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,SpriteAtlas} from "cc"; +import { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,SpriteAtlas, BoxCollider2D} from "cc"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; import { smc } from "../common/SingletonModuleComp"; @@ -40,7 +40,8 @@ export class Monster extends ecs.Entity { var node = instantiate(prefab); var scene = smc.map.MapView.scene; node.parent = scene.entityLayer!.node! - + const collider = node.getComponent(BoxCollider2D); + if (collider) collider.enabled = false; // 先禁用 // 延迟一帧启用碰撞体 node.setPosition(pos) this.hero_init(uuid,node,scale,box_group,is_boss,is_call,lv,rogueBuffData) oops.message.dispatchEvent("monster_load",this) diff --git a/assets/script/game/skills/SkillCom.ts b/assets/script/game/skills/SkillCom.ts index 6fc33555..c5a681f8 100644 --- a/assets/script/game/skills/SkillCom.ts +++ b/assets/script/game/skills/SkillCom.ts @@ -193,11 +193,12 @@ export class SkillCom extends CCComp { } onBeginContact (seCol: Collider2D, oCol: Collider2D) { - // //console.log(this.scale+"碰撞开始 ",seCol,oCol); + console.log(this.scale+"碰撞开始 ",seCol,oCol); + if(seCol.node.position.x-oCol.node.position.x > 100 ) return let target = oCol.getComponent(HeroViewComp) if(oCol.group!=this.group){ if(target == null) return; - console.log("[SkillCom]:onBeginContact oCol||seCol",oCol.node.position,seCol.node.position) + // console.log("[SkillCom]:onBeginContact oCol||seCol",oCol.node.position,seCol.node.position) this.single_damage(target) // this.ent.destroy() }