diff options
author | romulox_x <romulox_x@yahoo.com> | 2014-10-12 20:20:56 -0700 |
---|---|---|
committer | romulox_x <romulox_x@yahoo.com> | 2014-10-12 20:20:56 -0700 |
commit | 299bccdee99a9858f3bb874c70bd435151018e3a (patch) | |
tree | d3d1491ac4e88b8316470f48c05a99ba0858004a /scene/2d | |
parent | 948fd83cdded7fed77ae5213101c1a2ece580434 (diff) |
offset particle drawing order so that recently emitted particles are always drawn on top of the older ones
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/particles_2d.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index ded86702ef..819b06e095 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -507,7 +507,13 @@ void Particles2D::_notification(int p_what) { } - for(int i=0;i<particle_count;i++) { + int start_particle = (int)(time * (float)particle_count / lifetime); + + for (int id=0;id<particle_count;++id) { + int i = start_particle + id; + if (i >= particle_count) { + i -= particle_count; + } Particle &p=pdata[i]; if (!p.active) |