防止粒子系统在 qml 中永远运行



我正在尝试在我的应用程序中使粒子效果,一切都做得很好,除了我不能限制发射器并使其从自身停止而无需调用 ParticleSystem 的 stop 方法尽管我已将maximumEmitted设置为 100,但为了说明,这是我的代码:

import QtQuick 2.3
import QtQuick.Window 2.2
import QtQuick.Particles 2.0
Window {
visible: true
width: 360
height: 360

ParticleSystem{
    id:par
 anchors.centerIn: parent
running: true
 ImageParticle{
     id:imagepar
     source:"../../star_white.png"
    color:"red"
 }

 Emitter{
     id:myEmit
     width:1 ; height:1
    // anchors.centerIn: parent
     size:10
     emitRate: 100
     maximumEmitted: 100
     lifeSpan: 4000
     velocity: AngleDirection{
        angle: 180
        angleVariation: 5
        magnitude: 150
    }
 }
 Gravity {
     width: parent.width
     y: 150
     angle: 90
     magnitude: 150
 }

}

}

我已经尝试了以下方法,通过仅发射一次来使粒子停止自身,但不幸的是,它永远发射

 Age {
     system: par
     once: true
  }

 Affector {
     system: par
     once: true
 }

我想我在这里缺少一行代码,这将使它变得很好,任何想法。

我想到的第一件事:

Emitter {
    id: myEmit
    ....
    enabled: false
    Component.onCompleted: myEmit.pulse(1000)
    ....
}

最新更新