Qt 6.11 is out! See what's new in the release
blog
How to reuse objects
-
Why is it not creating the particles? i'm not getting any error but the particles aint visible:
import QtQuick 2.5 import QtQuick.Particles 2.0 Rectangle { id: root color: "transparent" ParticleSystem { id: x } ParticleSystem { id: y } Component { id: custom Item { ImageParticle { source: 'qrc:/files/particles/assets/particle.png' color: '#ff4208' colorVariation: 0.2 rotation: 10 rotationVariation: 20 rotationVelocity: 20 rotationVelocityVariation: 20 entryEffect: ImageParticle.Scale opacity: 1 } Emitter { property string _id: "" anchors.left: parent.left anchors.right: parent.right width: parent.width height: parent.height velocity: AngleDirection { angle: 270 angleVariation: 180 magnitude: 12 magnitudeVariation: 20 } } } } function createEmitter(properties) { var obj = custom.createObject(root); for (var i = 0; i < obj.children.length; i++) { var children = obj.children[i]; if (children instanceof ImageParticle) { children.system = properties.system; continue; } if (children instanceof Emitter) { children._id = properties.id; children.system = properties.system; children.emitRate = properties.emitRate; children.lifeSpan = properties.lifeSpan; children.lifeSpanVariation = properties.lifeSpanVariation; children.size = properties.size; children.maximumEmitted = properties.maximumEmitted; continue; } } } Component.onCompleted: { createEmitter({ 'id' : 'emitter1', 'system' : x, 'emitRate' : 40, 'lifeSpan' : 4000, 'lifeSpanVariation': 8000, 'size' : 52, 'maximumEmitted' : 20 }); createEmitter({ 'id' : 'emitter2', 'system' : y, 'emitRate' : 50, 'lifeSpan' : 5000, 'lifeSpanVariation': 9000, 'size' : 62, 'maximumEmitted' : 30 }); }