我正在使用 qml 中的粒子系统,但我希望我的粒子来自我的矩形的中心。
前面我可以告诉你它已经完成了,但是我不喜欢的是,这些粒子出现了混乱而没有方向。
我希望粒子从中心到末端均匀分布,但我不知道该怎么做
如果有人我可以提出一些想法。
我附上我的代码。
接受解决我问题的更正,想法或建议。
import QtQuick 2.0
import QtQuick.Particles 2.0
Rectangle {
id: bg
width: 360
height: 360
color: "black"
ParticleSystem {
id: particleSys
}
Emitter{
id: emitter
anchors.centerIn: parent
height: 14; width: 16
system: particleSys
emitRate: 80
lifeSpan: 4000
lifeSpanVariation: 500
maximumEmitted: 1000
size: 5
endSize: 40
velocity: TargetDirection{
targetX: 0; targetY: 0
targetVariation: 360
magnitude: 250
}
}
ImageParticle{
source: "images/blueBlip.png" //My image
system: particleSys
}
}
感谢。
答案 0 :(得分:1)
我是问这个问题的人 我找到了解决问题的方法。
要发出有序粒子,您可以使用 burst() 方法。
此事件允许我们从发射器发射一定数量的粒子。您可以根据需要进行操作。
我是通过Timmer实现的:
RewriteCond %{HTTP_HOST} ^www\..* [NC]
RewriteRule ^\/conteudo\/(.*)$ http://menusite.com.br/content/$1 [R=301,L]
代码如下所示:
Timer{
interval: 500; running: true; repeat: true
onTriggered: particles.burst(particles.emitRate)
}
如果有人知道一种更有效的方式,或者有人可以改进它......请提供答案 感谢。
答案 1 :(得分:0)
谢谢!
虽然您不需要计时器!您只需要调用一次particles.burst()即可开始。每半秒钟调用一次可能会减慢速度。相反,您应该将发射器的开始时间设置为0。
import QtQuick 2.0
import QtQuick.Particles 2.0
Rectangle {
id: bg
width: 360
height: 360
color: "black"
ParticleSystem {
id: particleSys
}
Emitter{
id: particles
startTime: 0
anchors.centerIn: parent
height: 14; width: 16
system: particleSys
emitRate: 80
lifeSpan: 4000
lifeSpanVariation: 500
maximumEmitted: 1000
size: 5
endSize: 40
velocity: TargetDirection{
targetX: 0; targetY: 0
targetVariation: 360
magnitude: 250
}
}
ImageParticle {
source: "images/blueBlip.png" //My image
system: particleSys
}
}
或者您可以在特定事件(例如Component.onCompleted)上调用particle.burst():
Emitter{
id: particles
anchors.centerIn: parent
height: 14; width: 16
system: particleSys
emitRate: 80
lifeSpan: 4000
lifeSpanVariation: 500
maximumEmitted: 1000
size: 80
endSize: 100
velocity: TargetDirection{
targetX: 0; targetY: 0
targetVariation: 360
magnitude: 250
}
Component.onCompleted: {
particles.burst(particles.emitRate)
}
}