我在对象池中put了20个雨滴,每一个雨滴上都有蓝色粒子特效,蓝色粒子特效能在0.5秒的时候播放完毕,产生粒子动画的两秒以后我才将雨滴put会对象池,但是重新生成的雨滴多多少少都会有一些灰色的粒子跟随在雨滴周围,不知道是什么原因,向大家求助一下
//开始时候初始化雨滴下落
initBullet_Rain_Start(){
let bullet_Rain=this._Bullet_RainPool.get();
if(!bullet_Rain){
bullet_Rain=cc.instantiate(this.Bullet_RainPerfab);
}
//初始化雨滴一开始的位置
// cc.loader.loadRes("RainBoom",cc.ParticleSystem,function(error,resource)
// {
// if(error){
// cc.log(error);
// }
// if(bullet_Rain.children[1].getComponent(cc.ParticleSystem)===null)
// {
// bullet_Rain.children[1].addComponent(cc.ParticleSystem);
// }
// bullet_Rain.children[1].getComponent(cc.ParticleSystem).file=resource;
// });
//cc.log("file="+bullet_Rain.getComponent(cc.ParticleSystem).file);
bullet_Rain.setPosition(cc.v2(this.Random(this.AllRain.getPosition().x,-cc.winSize.width/2),500));
bullet_Rain.runAction(
cc.sequence(
//雨滴移动到下方
cc.moveTo(3,bullet_Rain.getPosition().x,-250),
cc.callFunc(()=>{
//雨滴移动完成以后,大小变为0
bullet_Rain.children[0].runAction(
cc.scaleTo(0.1,0),
)
//雨滴移动完成以后,开始粒子特效
bullet_Rain.children[1].getComponent(cc.ParticleSystem).resetSystem();
// cc.log(bullet_Rain.children[1].getComponent(cc.ParticleSystem).particleCount);
// cc.log(bullet_Rain.children[1].getComponent(cc.ParticleSystem).stopped);
},this),
//延迟两秒
cc.delayTime(2),
cc.callFunc(()=>{
//延迟两秒以后,恢复scale形状大小
//cc.log(bullet_Rain.children[1].getComponent(cc.ParticleSystem).particleCount);
cc.log(bullet_Rain.children[1].getComponent(cc.ParticleSystem).stopped);
bullet_Rain.children[0].scaleX=0.5;
bullet_Rain.children[0].scaleY=1;
//延迟两秒以后,恢复形状大小
//bullet_Rain.children[1].removeComponent(cc.ParticleSystem);
this._Bullet_RainPool.put(bullet_Rain);
},this)
)
);
//将这个对象添加到这个脚本的子对象上
this.node.addChild(bullet_Rain);
},


