diff options
author | clayjohn <claynjohn@gmail.com> | 2019-06-20 11:20:27 -0700 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2019-06-25 22:07:29 -0700 |
commit | d59dbda24f780b1e52681b604ead650acd065a22 (patch) | |
tree | 13b1874a0f5a5df3bc42475e4c0a503a908b4249 /scene/2d/particles_2d.cpp | |
parent | 5a29be31b3055e218107df50bbbebdc0865026e8 (diff) |
update emitting status on one-shot particles
Diffstat (limited to 'scene/2d/particles_2d.cpp')
-rw-r--r-- | scene/2d/particles_2d.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index 9701998f5d..4043b8d587 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -41,6 +41,12 @@ void Particles2D::set_emitting(bool p_emitting) { VS::get_singleton()->particles_set_emitting(particles, p_emitting); + + if (p_emitting && one_shot) { + set_process_internal(true); + } else if (!p_emitting) { + set_process_internal(false); + } } void Particles2D::set_amount(int p_amount) { @@ -60,8 +66,16 @@ void Particles2D::set_one_shot(bool p_enable) { one_shot = p_enable; VS::get_singleton()->particles_set_one_shot(particles, one_shot); - if (!one_shot && is_emitting()) - VisualServer::get_singleton()->particles_restart(particles); + + if (is_emitting()) { + + set_process_internal(true); + if (!one_shot) + VisualServer::get_singleton()->particles_restart(particles); + } + + if (!one_shot) + set_process_internal(false); } void Particles2D::set_pre_process_time(float p_time) { @@ -313,6 +327,14 @@ void Particles2D::_notification(int p_what) { if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { _update_particle_emission_transform(); } + + if (p_what == NOTIFICATION_INTERNAL_PROCESS) { + + if (one_shot && !is_emitting()) { + _change_notify(); + set_process_internal(false); + } + } } void Particles2D::_bind_methods() { |