Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter flame camera shake deprecated

enter image description here

When I tried to repeat some lecture of flutter flame, most of youtube instructors teach me this way to shake screen. But IDE complaint using camera property directly was deprecated.

So, What is best way to shake camera (or viewport or world) now days?

try

  • camera.shake(); // deprecated
  • gameRef.camera.shake(); // deprecated
  • gameRef.world.shake(); // method not exists
  • gameRef.cameraComponent.shake(); // method not exists
  • gameRef.cameraComponent.viewport.shake(); // method not exists
  • gameRef.cameraComponent.camera.shake(); // method not exists

expect

  • no deprecated
like image 337
김종현 Avatar asked Aug 31 '26 23:08

김종현


1 Answers

The shaking of the camera has become an effect instead of a method directly on the camera, this is how you can use it with the CameraComponent:

        cameraComponent.viewfinder.add(
          MoveEffect.by(
            Vector2(5, 5),
            PerlinNoiseEffectController(duration: 0.2, frequency: 400),
          ),
        );

And of course change the parameters to your liking.

Remember to import flame_noise, since that EffectController resides in there: https://pub.dev/packages/flame_noise

like image 66
spydon Avatar answered Sep 02 '26 14:09

spydon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!