Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Static Color bug via Qt particles
Forum Updated to NodeBB v4.3 + New Features

Static Color bug via Qt particles

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 104 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jay_emissary
    wrote last edited by
    #1

    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.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jonas Karlsson
      wrote last edited by
      #2

      Could you put your complete code in one qml file so we can more easily test your exact setup?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved