this.schedule(()=>{
const bul = instantiate(this.bullet)
const bul1 = instantiate(this.bullet)
this.Canvas.addChild(bul)
this.Canvas.addChild(bul1)
const x = this.me1.position.x
const y = this.me1.position.y
bul.setPosition(x-10,y+60)
bul1.setPosition(x+10,y+60)
const comp = bul.getComponent(Collider2D)
comp.on(Contact2DType.BEGIN_CONTACT,(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null)=>{
setTimeout(()=>{
selfCollider.node.destroy();
}, 500)
},this);
const comp1 = bul1.getComponent(Collider2D)
comp.on(Contact2DType.BEGIN_CONTACT,(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null)=>{
setTimeout(()=>{
selfCollider.node.destroy();
}, 500)
},this);
},0.25)
CocosCreator3.8.2,想要实现实例化同一种预制体,在不同位置生成,与某物体碰撞后消失。但是这段代码不能实现该效果