Qt6 QML Book/图形效果/粒子参数

Particle Parameters

粒子参数

We saw already how to change the behavior of the emitter to change our simulation. The particle painter used allows us how the particle image is visualized for each particle.

我们已经看到了如何改变发射器的行为来改变我们的仿真。使用的粒子绘制器可以让我们看到每个粒子的粒子图像。

Coming back to our example we update our ImageParticle. First, we change our particle image to a small sparking star image:

回到我们的例子,我们更新了ImageParticle。首先,我们将粒子图像更改为一个小的亮星图像:

ImageParticle {
    ...
    source: 'assets/star.png'
}

The particle shall be colorized in an gold color which varies from particle to particle by +/- 20%:

颗粒的颜色应为金色,不同颗粒的颜色相差+/-20%:

color: '#FFD700'
colorVariation: 0.2

To make the scene more alive we would like to rotate the particles. Each particle should start by 15 degrees clockwise and varies between particles by +/-5 degrees. Additional the particle should continuously rotate with the velocity of 45 degrees per second. The velocity shall also vary from particle to particle by +/- 15 degrees per second:

为了使场景更生动,我们希望旋转粒子。每个粒子应以顺时针15度开始,并在粒子之间变化+/-5度。另外,粒子应以每秒45度的速度持续旋转。颗粒之间的速度也应每秒变化+/-15度:

rotation: 15
rotationVariation: 5
rotationVelocity: 45
rotationVelocityVariation: 15

Last but not least, we change the entry effect for the particle. This is the effect used when a particle comes to life. In this case, we want to use the scale effect:

最后但并非最不重要的是,我们改变了粒子的进入效果。这是粒子复活时使用的效果。在这种情况下,我们希望使用缩放效果:

entryEffect: ImageParticle.Scale

So now we have rotating golden stars appearing all over the place.

所以现在我们有旋转的金星出现在各地。

Here is the code we changed for the image-particle in one block.

下面是我们为一个块中的图像粒子更改的代码。

ImageParticle {
    source: "assets/star.png"
    system: particleSystem
    color: '#FFD700'
    colorVariation: 0.2
    rotation: 0
    rotationVariation: 45
    rotationVelocity: 15
    rotationVelocityVariation: 15
    entryEffect: ImageParticle.Scale
}

 示例源码下载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值