Qt Quick Particles 예제 - 이미터

이 문서는 QML 입자 시스템에서 Emitter를 사용하는 예제 모음입니다.

6개의 회전하는 바퀴살 모양으로 꽃과 같은 무늬를 이루는 곡선형 입자들

이 문서는 파티클 시스템에서 Emitter를 사용하는 것과 관련된 간단한 QML 예제 모음입니다. 각 예제는 특정 유형이나 기능을 중점적으로 다루는 간단한 QML 파일로 구성되어 있습니다.

'motion'을 통한 속도 설정은 주로 이미터를 이동시켜 입자가 강하게 움직이는 효과를 냅니다:

Emitter {
    id: trailsNormal
    system: sys1

    emitRate: 500
    lifeSpan: 2000

    y: mouseArea.pressed ? mouseArea.mouseY : circle.cy
    x: mouseArea.pressed ? mouseArea.mouseX : circle.cx

    velocity: PointDirection {xVariation: 4; yVariation: 4;}
    acceleration: PointDirection {xVariation: 10; yVariation: 10;}
    velocityFromMovement: 8

    size: 8
    sizeVariation: 4
}

'Burst'와 'pulse'는 두 개의 동일한 에미터에 대해 각각 burst 및 pulse 메서드를 호출합니다.

    if (root.lastWasPulse) {
        burstEmitter.burst(500);
        root.lastWasPulse = false;
    } else {
        pulseEmitter.pulse(500);
        root.lastWasPulse = true;
    }

burst는 방출할 입자 수를 인수로 받고, pulse는 방출 지속 시간을 밀리초 단위로 인수로 받는 점에 유의하십시오. 이로 인해 약간 다른 동작이 나타나며, 이 예제에서 쉽게 확인할 수 있습니다.

'Custom Emitter'는 emitParticles 신호에 연결되어 입자가 방출될 때 입자 데이터에 임의의 값을 설정합니다.

onEmitParticles: (particles) => {
    for (var i=0; i<particles.length; i++) {
        let particle = particles[i];
        particle.startSize = Math.max(02,Math.min(492,Math.tan(particle.t/2)*24));
        let theta = Math.floor(Math.random() * 6.0);
        particle.red = theta == 0 || theta == 1 || theta == 2 ? 0.2 : 1;
        particle.green = theta == 2 || theta == 3 || theta == 4 ? 0.2 : 1;
        particle.blue = theta == 4 || theta == 5 || theta == 0 ? 0.2 : 1;
        theta /= 6.0;
        theta *= 2.0*Math.PI;
        theta += sys.convert(sys.petalRotation);//Convert from degrees to radians
        particle.initialVX = sys.petalLength * Math.cos(theta);
        particle.initialVY = sys.petalLength * Math.sin(theta);
        particle.initialAX = particle.initialVX * -0.5;
        particle.initialAY = particle.initialVY * -0.5;
    }
}

이 기능은 6개의 회전하는 스포크 형태로 곡선을 그리며 입자를 방출하는 데 사용됩니다.

Emit mask는 에미터에 이미지 마스크를 설정하여 임의의 모양을 따라 입자를 방출합니다.

shape: MaskShape {
    source: "images/starfish_mask.png"
}

'Maximum emitted'는 한 번에 특정 개수 이상의 입자를 방출하지 않도록 제한합니다. 이 예제를 통해 제한에 도달했을 때 어떤 현상이 발생하는지 쉽게 확인할 수 있습니다.

'Shape'와 'Direction'은 채워지지 않은 타원 모양 밖으로 입자를 방출하며, TargetDirection

shape: EllipseShape {fill: false}
velocity: TargetDirection {
    targetX: root.width/2
    targetY: root.height/2
    proportionalMagnitude: true
    magnitude: 0.5
}

이렇게 하면 입자들이 타원의 윤곽선을 유지한 채 중심을 향해 비례적인 속도로 이동합니다.

TrailEmitter 이 유형을 사용하여 씬에서 불 입자 뒤를 따라가는 연기 입자를 추가합니다.

onEmitParticles: (particles) => {
    for (var i=0; i<particles.length; i++) {
        let particle = particles[i];
        particle.startSize = Math.max(02,Math.min(492,Math.tan(particle.t/2)*24));
        let theta = Math.floor(Math.random() * 6.0);
        particle.red = theta == 0 || theta == 1 || theta == 2 ? 0.2 : 1;
        particle.green = theta == 2 || theta == 3 || theta == 4 ? 0.2 : 1;
        particle.blue = theta == 4 || theta == 5 || theta == 0 ? 0.2 : 1;
        theta /= 6.0;
        theta *= 2.0*Math.PI;
        theta += sys.convert(sys.petalRotation);//Convert from degrees to radians
        particle.initialVX = sys.petalLength * Math.cos(theta);
        particle.initialVY = sys.petalLength * Math.sin(theta);
        particle.initialAX = particle.initialVX * -0.5;
        particle.initialAY = particle.initialVY * -0.5;
    }
}

예제 프로젝트 @ code.qt.io

© 2026 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.