diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/declarative/particles/affectors/customaffector.qml | 48 | ||||
-rw-r--r-- | examples/declarative/particles/emitters/customemitter.qml | 21 |
2 files changed, 39 insertions, 30 deletions
diff --git a/examples/declarative/particles/affectors/customaffector.qml b/examples/declarative/particles/affectors/customaffector.qml index 35708b7864..e9aea62a5a 100644 --- a/examples/declarative/particles/affectors/customaffector.qml +++ b/examples/declarative/particles/affectors/customaffector.qml @@ -71,7 +71,7 @@ Item { property real speed: 1.5 width: parent.width height: parent.height - 100 - onAffectParticle:{ + onAffectParticles:{ /* //Linear movement if (particle.r == 0){ particle.r = Math.random() > 0.5 ? -1 : 1; @@ -86,14 +86,17 @@ Item { } */ //Wobbly movement - if (particle.r == 0.0){ - particle.r = Math.random() + 0.01; + 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 += speed * particle.r * dt; + particle.r -= particle.rotation * coefficient; + if (particle.r == 0.0) + particle.r -= particle.rotation * 0.000001; + particle.update = 1; } - particle.rotation += speed * particle.r * dt; - particle.r -= particle.rotation * coefficient; - if (particle.r == 0.0) - particle.r -= particle.rotation * 0.000001; - particle.update = 1; } } @@ -104,19 +107,22 @@ Item { width: parent.width + 120 height: 100 anchors.bottom: parent.bottom - onAffectParticle:{ - var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1; - var yslow = pseudoRand * 0.01 + 1.01; - var xslow = pseudoRand * 0.005 + 1.0; - if (particle.vy < 1) - particle.vy = 0; - else - particle.vy = (particle.vy / yslow); - if (particle.vx < 1) - particle.vx = 0; - else - particle.vx = (particle.vx / xslow); - particle.update = 1; + onAffectParticles:{ + for (var i=0; i<particles.length; i++) { + var particle = particles[i]; + var pseudoRand = (Math.floor(particle.t*1327) % 10) + 1; + var yslow = dt * pseudoRand * 0.5 + 1; + var xslow = dt * pseudoRand * 0.05 + 1; + if (particle.vy < 1) + particle.vy = 0; + else + particle.vy = (particle.vy / yslow); + if (particle.vx < 1) + particle.vx = 0; + else + particle.vx = (particle.vx / xslow); + particle.update = 1; + } } } ImageParticle{ diff --git a/examples/declarative/particles/emitters/customemitter.qml b/examples/declarative/particles/emitters/customemitter.qml index 55c3884a11..39e2d066f6 100644 --- a/examples/declarative/particles/emitters/customemitter.qml +++ b/examples/declarative/particles/emitters/customemitter.qml @@ -66,15 +66,18 @@ ParticleSystem{ emitRate: 120 size: 12 anchors.centerIn: parent - onEmitParticle:{ - particle.startSize = Math.max(02,Math.min(492,Math.tan(particle.t/2)*24)); - var theta = Math.floor(Math.random() * 6.0) / 6.0; - theta *= 2.0*Math.PI; - theta += sys.convert(sys.petalRotation); - particle.initialVX = petalLength * Math.cos(theta); - particle.initialVY = petalLength * Math.sin(theta); - particle.initialAX = particle.initialVX * -0.5; - particle.initialAY = particle.initialVY * -0.5; + onEmitParticles:{ + for (var i=0; i<particles.length; i++) { + var particle = particles[i]; + particle.startSize = Math.max(02,Math.min(492,Math.tan(particle.t/2)*24)); + var theta = Math.floor(Math.random() * 6.0) / 6.0; + theta *= 2.0*Math.PI; + theta += sys.convert(sys.petalRotation); + particle.initialVX = petalLength * Math.cos(theta); + particle.initialVY = petalLength * Math.sin(theta); + particle.initialAX = particle.initialVX * -0.5; + particle.initialAY = particle.initialVY * -0.5; + } } } ImageParticle{ |