diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-09-13 09:39:11 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-13 04:53:33 +0200 |
commit | 29993ff8e91715bdfbaf964c91e07a112f6d2a24 (patch) | |
tree | 46a7b25ba1091f1d6ada9decaa9bf9d77d3a8004 /examples/declarative/particles | |
parent | 4dba5720e03542e0989adad2461358074c7d0dee (diff) |
Refactor SpriteEngine out of StochasticEngine
Also add ParticleGroups which use only StochasticStates
Simplistic change for now, just to focus the API for the
particle system. ParticleGroup elements replace the particleStates
property on the system, and the term "group" is now used more
consistently.
Change-Id: I6456f9c521b8166ccd94ea953275557bcfbf6423
Reviewed-on: http://codereview.qt-project.org/4699
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'examples/declarative/particles')
9 files changed, 126 insertions, 132 deletions
diff --git a/examples/declarative/particles/allsmiles/smilefactory.qml b/examples/declarative/particles/allsmiles/smilefactory.qml index fe651491b9..4b01862f99 100644 --- a/examples/declarative/particles/allsmiles/smilefactory.qml +++ b/examples/declarative/particles/allsmiles/smilefactory.qml @@ -48,7 +48,7 @@ Rectangle{ ParticleSystem{id:sys} ImageParticle{ system: sys - particles: ["goingLeft", "goingRight"] + groups: ["goingLeft", "goingRight"] source: "content/singlesmile.png" rotation: 90 rotationSpeed: 90 @@ -56,7 +56,7 @@ Rectangle{ } ImageParticle{ system: sys - particles: ["goingDown"] + groups: ["goingDown"] source: "content/squarefacespriteXX.png" yVector: PointDirection{ y: 0.5; yVariation: 0.25; xVariation: 0.25; } rotation: 180 @@ -85,7 +85,7 @@ Rectangle{ y: 120 system: sys enabled: false - particle: "goingRight" + group: "goingRight" speed: PointDirection{ x: 100 } lifeSpan: 4000 emitRate: 2 @@ -97,7 +97,7 @@ Rectangle{ y: 240 system: sys enabled: false - particle: "goingLeft" + group: "goingLeft" speed: PointDirection{ x: -100 } lifeSpan: 4000 emitRate: 2 @@ -109,7 +109,7 @@ Rectangle{ y: 360 system: sys enabled: false - particle: "goingDown" + group: "goingDown" speed: PointDirection{ x: 100 } lifeSpan: 4000 emitRate: 2 diff --git a/examples/declarative/particles/allsmiles/spriteparticles.qml b/examples/declarative/particles/allsmiles/spriteparticles.qml index 705016e050..0586dfd8db 100644 --- a/examples/declarative/particles/allsmiles/spriteparticles.qml +++ b/examples/declarative/particles/allsmiles/spriteparticles.qml @@ -47,7 +47,7 @@ Rectangle{ height: 400 ImageParticle{ id: test - particles: ["Test"] + groups: ["Test"] source: "content/particle.png" system: sys z: 2 @@ -57,7 +57,7 @@ Rectangle{ } ImageParticle{ id: single - particles: ["Face"] + groups: ["Face"] system: sys z: 2 anchors.fill: parent @@ -73,7 +73,7 @@ Rectangle{ } Emitter{ system: sys - particle: "Test" + group: "Test" anchors.fill: parent id: particles2 emitRate: 6000 @@ -83,7 +83,7 @@ Rectangle{ } Emitter{ system: sys - particle: "Face" + group: "Face" anchors.fill: parent id: particles emitRate: 60 diff --git a/examples/declarative/particles/asteroid/asteroid.qml b/examples/declarative/particles/asteroid/asteroid.qml index ea2fabd51d..6d556997c7 100644 --- a/examples/declarative/particles/asteroid/asteroid.qml +++ b/examples/declarative/particles/asteroid/asteroid.qml @@ -67,7 +67,7 @@ Item { } ImageParticle { system: sys - particles: ["starfield"] + groups: ["starfield"] source: "content/star.png" colorVariation: 0.3 color: "white" @@ -75,7 +75,7 @@ Item { Emitter { id: starField system: sys - particle: "starfield" + group: "starfield" emitRate: 80 lifeSpan: 2500 @@ -91,7 +91,7 @@ Item { } Emitter{ system: sys - particle: "meteor" + group: "meteor" emitRate: 12 lifeSpan: 5000 acceleration: PointDirection{ xVariation: 80; yVariation: 80; } @@ -101,7 +101,7 @@ Item { } ImageParticle{ system: sys - particles: ["meteor"] + groups: ["meteor"] sprites:[Sprite{ id: spinState name: "spinning" @@ -126,7 +126,7 @@ Item { ] } SpriteGoal{ - particles: ["meteor"] + groups: ["meteor"] system: sys goalState: "explode" jump: true @@ -170,7 +170,7 @@ Item { ImageParticle{ z:0 system: sys - particles: ["exhaust"] + groups: ["exhaust"] source: "content/particle4.png" color: "orange" @@ -193,7 +193,7 @@ Item { Emitter{ id: trailsNormal2 system: sys - particle: "exhaust" + group: "exhaust" emitRate: 300 lifeSpan: 500 diff --git a/examples/declarative/particles/asteroid/blackhole.qml b/examples/declarative/particles/asteroid/blackhole.qml index 7e8a7a9edc..00fca7ef3c 100644 --- a/examples/declarative/particles/asteroid/blackhole.qml +++ b/examples/declarative/particles/asteroid/blackhole.qml @@ -66,7 +66,7 @@ Rectangle{ } Emitter{ - particle: "stars" + group: "stars" system: particles emitRate: 40 lifeSpan: 4000 @@ -77,7 +77,7 @@ Rectangle{ height: parent.height } Emitter{ - particle: "roids" + group: "roids" system: particles emitRate: 10 lifeSpan: 4000 @@ -93,7 +93,7 @@ Rectangle{ } ImageParticle{ id: stars - particles: ["stars"] + groups: ["stars"] system: particles source: "content/star.png" color: "white" @@ -102,7 +102,7 @@ Rectangle{ } ImageParticle{ id: roids - particles: ["roids"] + groups: ["roids"] system: particles sprites: Sprite{ id: spinState @@ -115,7 +115,7 @@ Rectangle{ } ImageParticle{ id: shot - particles: ["shot"] + groups: ["shot"] system: particles source: "content/star.png" @@ -124,7 +124,7 @@ Rectangle{ } ImageParticle{ id: engine - particles: ["engine"] + groups: ["engine"] system: particles source: "content/particle4.png" @@ -170,7 +170,7 @@ Rectangle{ drag.target: ship } Emitter{ - particle: "engine" + group: "engine" system: particles emitRate: 200 lifeSpan: 1000 @@ -182,7 +182,7 @@ Rectangle{ width: 20 } Emitter{ - particle: "shot" + group: "shot" system: particles emitRate: 32 lifeSpan: 2000 diff --git a/examples/declarative/particles/trails/combustion.qml b/examples/declarative/particles/trails/combustion.qml index e4a21e9beb..238dbe8a79 100644 --- a/examples/declarative/particles/trails/combustion.qml +++ b/examples/declarative/particles/trails/combustion.qml @@ -57,71 +57,67 @@ Rectangle { ParticleSystem{ id: particles anchors.fill: parent + ParticleGroup{ + name: "unlit" + duration: 1000 + to: {"lighting":1, "unlit":99} + ImageParticle{ + source: "content/particleA.png" + colorVariation: 0.1 + color: "#2060160f" + } + SpriteGoal{ + whenCollidingWith: ["lit"] + goalState: "lighting" + jump: true + systemStates: true + } + } + ParticleGroup{ + name: "lighting" + duration: 100 + to: {"lit":1} + } + ParticleGroup{ + name: "lit" + duration: 10000 + onEntered: score++; + TrailEmitter{ + id: fireballFlame + group: "flame" + emitRatePerParticle: 48 + lifeSpan: 200 + emitWidth: 8 + emitHeight: 8 - particleStates:[ - Sprite{ - name: "unlit" - duration: 1000 - to: {"lighting":1, "unlit":99} - ImageParticle{ - source: "content/particleA.png" - colorVariation: 0.1 - color: "#2060160f" - } - SpriteGoal{ - whenCollidingWith: ["lit"] - goalState: "lighting" - jump: true - systemStates: true - } - }, - Sprite{ - name: "lighting" - duration: 100 - to: {"lit":1} - }, - Sprite{ - name: "lit" - duration: 10000 - onEntered: score++; - TrailEmitter{ - id: fireballFlame - particle: "flame" - - emitRatePerParticle: 48 - lifeSpan: 200 - emitWidth: 8 - emitHeight: 8 - - size: 24 - sizeVariation: 8 - endSize: 4 - } + size: 24 + sizeVariation: 8 + endSize: 4 + } - TrailEmitter{ - id: fireballSmoke - particle: "smoke" + TrailEmitter{ + id: fireballSmoke + group: "smoke" - emitRatePerParticle: 120 - lifeSpan: 2000 - emitWidth: 16 - emitHeight: 16 + emitRatePerParticle: 120 + lifeSpan: 2000 + emitWidth: 16 + emitHeight: 16 - speed: PointDirection{yVariation: 16; xVariation: 16} - acceleration: PointDirection{y: -16} + speed: PointDirection{yVariation: 16; xVariation: 16} + acceleration: PointDirection{y: -16} - size: 24 - sizeVariation: 8 - endSize: 8 - } + size: 24 + sizeVariation: 8 + endSize: 8 } - ] + } ImageParticle{ id: smoke anchors.fill: parent - particles: ["smoke"] + groups: ["smoke"] source: "content/particle.png" colorVariation: 0 color: "#00111111" @@ -129,7 +125,7 @@ Rectangle { ImageParticle{ id: pilot anchors.fill: parent - particles: ["pilot"] + groups: ["pilot"] source: "content/particle.png" redVariation: 0.01 blueVariation: 0.4 @@ -138,7 +134,7 @@ Rectangle { ImageParticle{ id: flame anchors.fill: parent - particles: ["flame", "lit", "lighting"] + groups: ["flame", "lit", "lighting"] source: "content/particleA.png" colorVariation: 0.1 color: "#00ff400f" @@ -152,14 +148,14 @@ Rectangle { sizeVariation: 4 speed: PointDirection{x:120; xVariation: 80; yVariation: 50} acceleration: PointDirection{y:120} - particle: "unlit" + group: "unlit" } Emitter{ id: flamer x: 100 y: 300 - particle: "pilot" + group: "pilot" emitRate: 80 lifeSpan: 600 size: 24 @@ -167,7 +163,7 @@ Rectangle { endSize: 0 speed: PointDirection{ y:-100; yVariation: 4; xVariation: 4 } SpriteGoal{ - particles: ["unlit"] + groups: ["unlit"] goalState: "lit" jump: true systemStates: true @@ -181,7 +177,7 @@ Rectangle { } //Click to enflame SpriteGoal{//TODO: Aux emiiters in the state definition (which allows the occasional ball to spontaneously combust) - particles: ["unlit"] + groups: ["unlit"] goalState: "lighting" jump: true systemStates: true diff --git a/examples/declarative/particles/trails/fireballs.qml b/examples/declarative/particles/trails/fireballs.qml index 97a0c0ac5f..c7c0420049 100644 --- a/examples/declarative/particles/trails/fireballs.qml +++ b/examples/declarative/particles/trails/fireballs.qml @@ -55,7 +55,7 @@ Rectangle { ImageParticle{ id: fireball anchors.fill: parent - particles: ["E"] + groups: ["E"] system: particles source: "content/particleA.png" colorVariation: 0.2 @@ -66,7 +66,7 @@ Rectangle { id: smoke system: particles anchors.fill: parent - particles: ["A", "B"] + groups: ["A", "B"] source: "content/particle.png" colorVariation: 0 color: "#00111111" @@ -75,7 +75,7 @@ Rectangle { id: flame anchors.fill: parent system: particles - particles: ["C", "D"] + groups: ["C", "D"] source: "content/particle.png" colorVariation: 0.1 color: "#00ff400f" @@ -83,7 +83,7 @@ Rectangle { Emitter{ id: fire system: particles - particle: "C" + group: "C" y: parent.height width: parent.width @@ -100,7 +100,7 @@ Rectangle { } TrailEmitter{ id: fireSmoke - particle: "B" + group: "B" system: particles follow: "C" width: root.width @@ -120,7 +120,7 @@ Rectangle { id: fireballFlame anchors.fill: parent system: particles - particle: "D" + group: "D" follow: "E" emitRatePerParticle: 120 @@ -137,7 +137,7 @@ Rectangle { id: fireballSmoke anchors.fill: parent system: particles - particle: "A" + group: "A" follow: "E" emitRatePerParticle: 128 @@ -155,7 +155,7 @@ Rectangle { Emitter{ id: balls system: particles - particle: "E" + group: "E" y: parent.height width: parent.width diff --git a/examples/declarative/particles/trails/fireworks.qml b/examples/declarative/particles/trails/fireworks.qml index 437d9ee3d6..6b370b3991 100644 --- a/examples/declarative/particles/trails/fireworks.qml +++ b/examples/declarative/particles/trails/fireworks.qml @@ -48,36 +48,34 @@ Rectangle{ ParticleSystem{ anchors.fill: parent id: syssy - particleStates:[ - Sprite{ - name: "fire" - duration: 2000 - durationVariation: 2000 - to: {"splode":1} - }, - Sprite{ - name: "splode" - duration: 400 - to: {"dead":1} - TrailEmitter{ - particle: "works" - emitRatePerParticle: 100 - lifeSpan: 1000 - maximumEmitted: 1200 - size: 8 - speed: AngleDirection{angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;} - acceleration: PointDirection{y:100; yVariation: 20} - } - }, - Sprite{ - name: "dead" - duration: 1000 - Affector{ - once: true - onAffected: worksEmitter.burst(400,x,y) - } + ParticleGroup{ + name: "fire" + duration: 2000 + durationVariation: 2000 + to: {"splode":1} + } + ParticleGroup{ + name: "splode" + duration: 400 + to: {"dead":1} + TrailEmitter{ + group: "works" + emitRatePerParticle: 100 + lifeSpan: 1000 + maximumEmitted: 1200 + size: 8 + speed: AngleDirection{angle: 270; angleVariation: 45; magnitude: 20; magnitudeVariation: 20;} + acceleration: PointDirection{y:100; yVariation: 20} + } + } + ParticleGroup{ + name: "dead" + duration: 1000 + Affector{ + once: true + onAffected: worksEmitter.burst(400,x,y) } - ] + } Timer{ interval: 6000 running: true @@ -87,7 +85,7 @@ Rectangle{ } Emitter{ id: startingEmitter - particle: "fire" + group: "fire" width: parent.width y: parent.height enabled: false @@ -98,7 +96,7 @@ Rectangle{ } Emitter{ id: worksEmitter - particle: "works" + group: "works" enabled: false emitRate: 100 lifeSpan: 1600 @@ -111,7 +109,7 @@ Rectangle{ acceleration: PointDirection{y:100; yVariation: 20} } ImageParticle{ - particles: ["works", "fire", "splode"] + groups: ["works", "fire", "splode"] source: "content/particle.png" entryEffect: ImageParticle.Scale } diff --git a/examples/declarative/particles/trails/portal.qml b/examples/declarative/particles/trails/portal.qml index 85efd9a594..adf620fd9b 100644 --- a/examples/declarative/particles/trails/portal.qml +++ b/examples/declarative/particles/trails/portal.qml @@ -54,7 +54,7 @@ Rectangle{ id: particles } ImageParticle{ - particles: ["center","edge"] + groups: ["center","edge"] anchors.fill: parent system: particles source: "content/particle.png" @@ -63,7 +63,7 @@ Rectangle{ } Emitter{ anchors.fill: parent - particle: "center" + group: "center" system: particles emitRate: 200 lifeSpan: 2000 @@ -80,7 +80,7 @@ Rectangle{ } Emitter{ anchors.fill: parent - particle: "edge" + group: "edge" startTime: 2000 system: particles emitRate: 4000 diff --git a/examples/declarative/particles/trails/turbulence.qml b/examples/declarative/particles/trails/turbulence.qml index 104bb10e80..13eae162f4 100644 --- a/examples/declarative/particles/trails/turbulence.qml +++ b/examples/declarative/particles/trails/turbulence.qml @@ -71,14 +71,14 @@ Rectangle{ strength: 32 } ImageParticle{ - particles: ["smoke"] + groups: ["smoke"] system: ps source: "content/particle.png" color: "#11111111" colorVariation: 0 } ImageParticle{ - particles: ["flame"] + groups: ["flame"] system: ps source: "content/particle.png" color: "#11ff400f" @@ -87,7 +87,7 @@ Rectangle{ Emitter{ anchors.centerIn: parent system: ps - particle: "flame" + group: "flame" emitRate: 120 lifeSpan: 1200 @@ -102,7 +102,7 @@ Rectangle{ width: root.width height: root.height/2 - 20 system: ps - particle: "smoke" + group: "smoke" follow: "flame" emitRatePerParticle: 1 @@ -119,7 +119,7 @@ Rectangle{ width: root.width height: root.height/2 - 40 system: ps - particle: "smoke" + group: "smoke" follow: "flame" emitRatePerParticle: 4 |