Skip to content

Commit

Permalink
Merge pull request #1905 from Jno1995/v2.2.1-release
Browse files Browse the repository at this point in the history
fixed particle autoRemoveOnFinish bug
  • Loading branch information
holycanvas committed Oct 25, 2019
2 parents ba80c2f + 5afd3c7 commit defe008
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cocos/editor-support/particle/ParticleSimulator.cpp
Expand Up @@ -99,13 +99,15 @@ ParticleSimulator::~ParticleSimulator()
void ParticleSimulator::stop()
{
_active = false;
_readyToPlay = false;
_elapsed = duration;
_emitCounter = 0;
}

void ParticleSimulator::reset()
{
_active = true;
_readyToPlay = true;
_elapsed = 0;
_emitCounter = 0;
_finished = false;
Expand Down Expand Up @@ -449,7 +451,7 @@ void ParticleSimulator::render(float dt)
assembler->updateIABuffer(0, mb->getGLVB(), mb->getGLIB());
assembler->updateIARange(0, indexStart, indexCount);

if (_particles.size() == 0 && !_active)
if (_particles.size() == 0 && !_active && !_readyToPlay)
{
_finished = true;
if (_finishedCallback)
Expand Down
1 change: 1 addition & 0 deletions cocos/editor-support/particle/ParticleSimulator.h
Expand Up @@ -228,6 +228,7 @@ class ParticleSimulator : public cocos2d::middleware::IMiddleware, public cocos2
private:
std::vector<Particle*> _particles;
bool _active = false;
bool _readyToPlay = true;
bool _finished = false;
float _elapsed = 0;
float _emitCounter = 0;
Expand Down

0 comments on commit defe008

Please sign in to comment.