affectors attract
This commit is contained in:
parent
26eb3b42a6
commit
bf28a92e31
|
@ -1,36 +1,25 @@
|
||||||
ParticleSystem
|
ParticleSystem
|
||||||
|
|
||||||
AttractionAffector
|
AttractionAffector
|
||||||
destination: 150 150
|
destination: 200 200
|
||||||
|
acceleration: 128
|
||||||
|
velocity-reduction-percent: 10
|
||||||
|
|
||||||
Emitter
|
Emitter
|
||||||
position: 100 100
|
position: 200 200
|
||||||
burstRate: 99
|
burstRate: 1
|
||||||
burstCount: 1
|
burstCount: 128
|
||||||
|
|
||||||
particle-duration: 999
|
particle-duration: 2
|
||||||
particle-position-radius: 0
|
particle-position-radius: 0
|
||||||
|
|
||||||
particle-velocity: 32
|
particle-velocity: 128
|
||||||
particle-velocity-angle: 0
|
particle-min-velocity-angle: 0
|
||||||
|
particle-max-velocity-angle: 360
|
||||||
|
|
||||||
particle-acceleration: 0
|
particle-acceleration: 0
|
||||||
|
|
||||||
particle-size: 24 24
|
particle-size: 32 32
|
||||||
particle-color: #ffff0044
|
particle-color: #33ff3344
|
||||||
particle-texture: circle2.png
|
particle-texture: circle2.png
|
||||||
|
|
||||||
Emitter
|
|
||||||
position: 150 150
|
|
||||||
burstRate: 99
|
|
||||||
burstCount: 1
|
|
||||||
|
|
||||||
particle-duration: 999
|
|
||||||
particle-position-radius: 0
|
|
||||||
|
|
||||||
particle-velocity: 0
|
|
||||||
particle-acceleration: 0
|
|
||||||
|
|
||||||
particle-size: 24 24
|
|
||||||
particle-color: #ffff0044
|
|
||||||
particle-texture: circle2.png
|
|
||||||
|
|
|
@ -56,6 +56,8 @@ bool AttractionAffector::load(const OTMLNodePtr& node)
|
||||||
m_destination = childNode->value<Point>();
|
m_destination = childNode->value<Point>();
|
||||||
else if(childNode->tag() == "acceleration")
|
else if(childNode->tag() == "acceleration")
|
||||||
m_acceleration = childNode->value<float>();
|
m_acceleration = childNode->value<float>();
|
||||||
|
else if(childNode->tag() == "velocity-reduction-percent")
|
||||||
|
m_reduction = childNode->value<float>();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +72,7 @@ void AttractionAffector::update(const ParticlePtr& particle, double elapsedTime)
|
||||||
if(d.length() == 0)
|
if(d.length() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PointF pVelocity = particle->getVelocity();
|
PointF pVelocity = particle->getVelocity() + (d / d.length() * m_acceleration * elapsedTime);
|
||||||
particle->setVelocity(pVelocity + (d / d.length()) * m_acceleration * elapsedTime);
|
|
||||||
|
particle->setVelocity(pVelocity - pVelocity * m_reduction/100.0 * elapsedTime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Point m_destination;
|
Point m_destination;
|
||||||
float m_acceleration;
|
float m_acceleration, m_reduction;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue