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