From bea93daec3ad4e3345c701e5dcce250c44d128f2 Mon Sep 17 00:00:00 2001 From: Philipp Sehmisch Date: Tue, 24 Jun 2008 12:29:33 +0000 Subject: Added particle property "follow-parent" which makes the particle move when its parent particle is moved. --- src/particle.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/particle.cpp') diff --git a/src/particle.cpp b/src/particle.cpp index fd45430c..3b3f5116 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -63,6 +63,7 @@ Particle::Particle(Map *map): mGravity(0.0f), mRandomnes(0), mBounce(0.0f), + mFollow(false), mTarget(NULL), mAcceleration(0.0f), mInvDieDistance(-1.0f), @@ -95,6 +96,8 @@ Particle::update() mAlive = false; } + Vector oldPos = mPos; + if (mAlive) { //calculate particle movement @@ -191,10 +194,19 @@ Particle::update() } } + Vector change = mPos - oldPos; + // Update child particles + for (ParticleIterator p = mChildParticles.begin(); p != mChildParticles.end();) { + //move particle with its parent if desired + if ((*p)->doesFollow()) + { + (*p)->moveBy(change); + } + //update particle if ((*p)->update()) { p++; -- cgit v1.2.3-60-g2f50