import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Particles 2.0
Window {
visible: true;
width: 600;
height: 400;
color: "lightblue";
id: root;
Rectangle {
id: target;
color: "transparent";
width: parent.width/2;
height: 100;
anchors.top: parent.top;
anchors.right: parent.right;
anchors.margins: 4;
}
ParticleSystem {
id: particleSystem;
}
Emitter {
id: emitter;
system: particleSystem; // 指定粒子系统
anchors.left: parent.left;
anchors.bottom: parent.bottom;
width: 80;
height: 80;
size: 20; // 粒子的开始大小
endSize: 190;
sizeVariation: 10; // 粒子大小变化
emitRate: 20; // 每秒发射的粒子数 默认是 10
lifeSpan: 4000; // 以毫秒为单位的粒子生存周期
lifeSpanVariation: 200;// 发射器生存器内发射的最大粒子数
velocity: TargetDirection { // 粒子的方向
targetItem: target;
targetX: target.width;
targetY: 0;
targetVariation: target.width/8; // 发散度
magnitude: root.height/3; // 速度
}
}
ImageParticle {
system: particleSystem;
source: "qrc:///bubble_1.png";
}
}
程序运行效果如下: