解决 预制体刚生成还没移到出生点就发生碰撞问题
This commit is contained in:
@@ -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>(Initialize);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user