QT粒子效果3

import QtQuick 2.6
import QtQuick.Particles 2.0

/*
 * 作者: yubo
 * 功能: 二维空间粒子发射器
 * 描述: 支持依照形状进行发射粒子,粒子发射方向和数量以及生命周期可控制,方向支持x和y两个方向,角度可变,粒子发射速度以及速率可变
 * 日期: 2018-07-12
 */
ParticleSystem {
    id: sys
    // 发射器状态
    property bool emitterStatus: true
    // 发射器粒子图片
    property string particleColor: "#cde0ff"
    // 发射器粒子颜色
    property string particleImage: ""
    // 发射器形状背景图片
    property string maskBackground: ""
    // 发射器角度
    property real senderAngle: 270
    running: emitterStatus
    // 背景图片ID
    property var backgroundId: background

    ImageParticle {
        id: part
        visible: emitterStatus
        system: sys
        groups: "A"
        color: particleColor
        width: 200
        height: 30
        source: particleImage
        rotation: 180
        rotationVariation: 180
        rotationVelocity: 15
        rotationVelocityVariation: 15
        entryEffect: ImageParticle.Scale
        autoRotation: true
    }

    Emitter {
        id: emitter
        system: sys
        width: background.width
        height: background.height
        emitRate: 10
        lifeSpan: 1500
        lifeSpanVariation: 1000
        size: 6 + 1
        sizeVariation: 4
        endSize: 1 + 1
        shape: MaskShape { source: maskBackground }
        group: "A"
        velocity: AngleDirection {
            angle: senderAngle
            magnitude: 30
            magnitudeVariation: 10
        }
    }

    Image {
        id: background
        source: maskBackground
    }
}


 

你可能感兴趣的:(QT)