Davoud
Davoud

Reputation: 2943

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

I've added a parallax images to the game in onLoad method of the Game class. How to change the parallax images during the game or other parameters, like speed of parallax images?

Upvotes: 1

Views: 448

Answers (1)

spydon
spydon

Reputation: 11552

If you have a ParallaxComponent called component you can change the layers by modifying 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);

If you want to speed up the whole parallax but keep the same multiplier on the different layers you can set component.parallax.baseVelocity instead.

Upvotes: 2

Related Questions