Fix CustomAffector example

Don't use particle.r which doesn't exist since the CustomParticle
removal. Make example a bit simpler without this.

Task-number: QTBUG-88173
Change-Id: Id994a9a58796e8194fdccd63c6439d4c19681a45
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Kaj Grönholm 2020-11-04 15:43:18 +02:00
parent 5fa85ded71
commit 4fd12eef18
1 changed files with 2 additions and 23 deletions

View File

@ -77,35 +77,14 @@ Item {
//! [0]
Affector {
property real coefficient: 0.1
property real velocity: 1.5
width: parent.width
height: parent.height - 100
onAffectParticles: (particles, dt) => {
/* //Linear movement
if (particle.r == 0) {
particle.r = Math.random() > 0.5 ? -1 : 1;
} else if (particle.r == 1) {
particle.rotation += velocity * dt;
if (particle.rotation >= maxAngle)
particle.r = -1;
} else if (particle.r == -1) {
particle.rotation -= velocity * dt;
if (particle.rotation <= -1 * maxAngle)
particle.r = 1;
}
*/
//Wobbly movement
for (var i=0; i<particles.length; i++) {
var particle = particles[i];
if (particle.r == 0.0) {
particle.r = Math.random() + 0.01;
}
particle.rotation += velocity * particle.r * dt;
particle.r -= particle.rotation * coefficient;
if (particle.r == 0.0)
particle.r -= particle.rotation * 0.000001;
particle.update = 1;
particle.rotation += particle.vx * 0.15 * dt;
particle.update = true;
}
}
}