Qt Quick パーティクルの例 - イメージパーティクル

QMLパーティクルシステムでアフェクタを使用する例集です。

これは、パーティクルシステムでアフェクタを使うことに関連した、小さなQMLの例を集めたものです。それぞれの例は、特定のタイプや特徴を強調した小さなQMLファイルです。

All at once では、ImageParticle のいくつかの機能を同時に紹介しています。

sprites: [
    Sprite {
        name: "bear"
        source: "images/bear_tiles.png"
        frameCount: 13
        frameDuration: 120
    }
]
colorVariation: 0.5
rotationVelocityVariation: 360
colorTable: "images/colortable.png"

Colored はシンプルなImageParticle 、いくつかのカラーバリエーションを示しています。

ImageParticle {
    anchors.fill: parent
    source: "qrc:///particleresources/star.png"
    alpha: 0
    alphaVariation: 0.2
    colorVariation: 1.0
}

Color Tableは、パーティクルの寿命にわたって色を設定し、固定の虹効果を提供します。

source: "qrc:///particleresources/glowdot.png"
colorTable: "images/colortable.png"
sizeTable: "images/colortable.png"

Deformationはヒトデのパーティクルを回転させたり、つぶしたりします。

ImageParticle {
    system: sys
    groups: ["goingLeft", "goingRight"]
    source: "images/starfish_4.png"
    rotation: 90
    rotationVelocity: 90
    autoRotation: true
}
ImageParticle {
    system: sys
    groups: ["goingDown"]
    source: "images/starfish_0.png"
    rotation: 180
    yVector: PointDirection { y: 0.5; yVariation: 0.25; xVariation: 0.25; }
}

Rotation は、パーティクルが進行方向に回転する autoRotate プロパティを示します。

Sharing は、複数の ImageParticles が同じパーティクルをレンダリングしようとするとどうなるかを示します。次のImageParticle は、ListView 内のパーティクルをレンダリングします:

ImageParticle {
    anchors.fill: parent
    system: particles
    source: "images/flower.png"
    alpha: 0.1
    color: "white"
    rotationVariation: 180
    z: -1
}

次のImageParticle はリストハイライトの中に配置され、パーティクルを他のImageParticle の上にレンダリングします。

ImageParticle {
    anchors.fill: parent
    system: particles
    source: "images/flower.png"
    color: "red"
    clip: true
    alpha: 1.0
}

このImageParticle では色とアルファを設定しているため、パーティクルが異なる色でレンダリングされることに注意してください。回転については何も指定していないので、他のImageParticle と回転を共有し、花は両方で同じように回転します。別のImageParticle 、rotationVariationを明示的に0に設定するだけで、回転を元に戻すことができることに注意してください。

Sprites では、イメージパーティクルを使用して、各パーティクルの静止画像の代わりにアニメーションスプライトをレンダリングしています。

サンプルプロジェクト @ code.qt.io

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.