是否可以在使用 Flutter Flame 的游戏过程中改变视差?

Is it possible to change parallax during the game using Flutter Flame?

我在游戏 class 的 onLoad 方法中向游戏添加了视差图像。如何在游戏过程中更改视差图像或其他参数,例如视差图像的速度?

如果您有一个名为 componentParallaxComponent,您可以通过修改 component.parallax.layers 来更改图层。

How to change the parallax images during the game

component.parallax.layers[i] = <a new parallax layer with a new image>

or other parameters, like speed of parallax images?

component.parallax.layers[i].velocityMultiplier.setValues(x, y);

如果您想加速整个视差但在不同图层上保持相同的乘数,您可以改为设置 component.parallax.baseVelocity