我有一个关于如何在预先存在的暂停,恢复和重新启动框架中实现粒子发射器的问题。Cocos2d/Cocos2d-x粒子系统暂停
现在我有包括该代码的暂停方法:
void GamePlayLayer::pause()
{
//pauses/resumes game mechanics
if(!isPaused){
pauseSchedulerAndActions();
isPaused = true;
cout << "\npaused game... isPaused = " << isPaused;
}else{
resume();
}
//pauses/resumes particle emitters
CCParticleSystemQuad* runner_emitter = runner.getExistingEmitter();
if(runner_emitter != NULL){
if(!isPaused){
runner_emitter->pauseSchedulerAndActions();
}else{
runner_emitter->resumeSchedulerAndActions();
}
}
}
我也有创建的粒子发射器执行以下操作:
CCParticleSystemQuad* Runner::getNewEmitter()
{
p_emitter = CCParticleSystemQuad::create("emitter_runner.plist");
//position is relative to the point we add it to -- use this so it follows the sprite when the runner moves
p_emitter->setPositionType(kCCPositionTypeRelative);
updateEmitterPosition();
p_emitter->retain();
//so we dont get extra emitters sticking around in the scene
p_emitter->setAutoRemoveOnFinish(true);
cout <<endl << "Emitter sent";
return p_emitter;
}
在考虑中的粒子发射器具有相关联的持续时间与它,让说2秒。现在,我想让我的暂停方法冻结粒子系统,这样当我不停顿时,粒子发射器会继续停止。
我现在遇到的问题是当我暂停时,粒子发射器继续。 “pauseSchedulerAndActions()”方法与粒子发射器分离,我知道它有自己的调度器。
无论我尝试什么,我都无法停止粒子发射器继续在p_emitter.setDuration()方法中设置的时间。
这是有问题的,因为如果我停下时,粒子发射器还没有达到它的持续时间,到时候我取消暂停持续时间了,它已被删除,因为我设置此标志:
p_emitter->setAutoRemoveOnFinish(true);
时创建发射器。此外,发射器从来没有实际停顿,所以它给人的印象是游戏实际上并没有停顿。
所以我的问题是,我如何完全冻结粒子发射器的方式,允许发射器恢复时,我不停顿?