Time for action – vanishing coins spawning particles
It is time now to practice our freshly acquired skills. The task is to add a particle effect to the game when the player collects coins. The coin will explode into a sprinkle of colorful stars when collected.
Start by declaring a particle system as filling the game scene, along with the particle painter definition:
ParticleSystem { id: coinParticles anchors.fill: parent // scene is the parent ImageParticle { source: "particle.png" colorVariation: 1 rotationVariation: 180 rotationVelocityVariation: 10 } }
Next, modify the definition of Coin to include an emitter:
Emitter { id: emitter system: coinParticles emitRate: 0 lifeSpan: 500 lifeSpanVariation: 100 velocity: AngleDirection { angleVariation: ...
Get Game Programming Using Qt now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.