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/trails | |
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/trails')
-rw-r--r-- | examples/declarative/particles/trails/combustion.qml | 116 | ||||
-rw-r--r-- | examples/declarative/particles/trails/fireballs.qml | 16 | ||||
-rw-r--r-- | examples/declarative/particles/trails/fireworks.qml | 62 | ||||
-rw-r--r-- | examples/declarative/particles/trails/portal.qml | 6 | ||||
-rw-r--r-- | examples/declarative/particles/trails/turbulence.qml | 10 |
5 files changed, 102 insertions, 108 deletions
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 |