aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorKaj Grönholm <kaj.gronholm@qt.io>2020-11-04 15:43:18 +0200
committerKaj Grönholm <kaj.gronholm@qt.io>2020-11-05 10:00:37 +0200
commit4fd12eef18204920b0974e7252eb6d97c4f1d485 (patch)
tree0f6ddbc0f69bbc063ded81f6c6e574a99936cdaa /examples
parent5fa85ded71f4bd81b6332d8aecda3edd658f7a39 (diff)
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>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/particles/affectors/content/customaffector.qml25
1 files changed, 2 insertions, 23 deletions
diff --git a/examples/quick/particles/affectors/content/customaffector.qml b/examples/quick/particles/affectors/content/customaffector.qml
index 6fabfb3ab2..76fc4dc302 100644
--- a/examples/quick/particles/affectors/content/customaffector.qml
+++ b/examples/quick/particles/affectors/content/customaffector.qml
@@ -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;
}
}
}