Static Color bug via Qt particles
-
Hey all, I'm trying to work with Qt's particle system and either stumbled upon a bug or failed to grasp the concept of changing a particle's color.
ParticleSystem{ id: explosionSystem anchors.fill: parent } Emitter{ id: explosionEmitter system: explosionSystem anchors.bottom: parent.bottom anchors.horizontalCenter: parent.horizontalCenter lifeSpan: 500 emitRate: 0 size: parent.height * .1 velocity: CumulativeDirection{ AngleDirection{ angleVariation: 360 magnitude: 400 magnitudeVariation: 50 } } ImageParticle { id: explosionImg system: explosionSystem source: "xxx.png" alpha: 0.2 color: "transparent" colorVariation: 0 } }
Here I have a system, which I use to make the particles burst in all directions at the press of a button. They can change color depending on which button I press:
function onButtonPressed(type){ if (type === 1){ explosionImg.colorVariation = 0 explosionImg.color = "red" } else if (type === 2){ explosionImg.colorVariation = 0 explosionImg.color = "blue" } console.log( explosionImg.color) explosionEmitter.burst(12) }
Here's the issue: on the first burst the particles explode using their default color (white), despite the color being logged as changed when I call console.log. Any burst after uses the assigned color.
This gave me hours of headache last night as I was trying different methods to get the color to change on every burst. At some point I just assumed Qt couldn't load particle colors fast enough for the color to show on time, but alas, after hours of banging my head against the wall, I realized this was the issue. Does anyone know the cause or a possible fix? I've looked all over but can't even find anyone who has replicated the issue.