Files
flame/examples/lib/stories/parallax/component.dart
Lukas Klingsbo 7e4bc1464e Fix parallax fullscreen bug when game is resized (#887)
* Fix parallax fullscreen bug when game is resized

* Test

Signed-off-by: Lukas Klingsbo <me@lukas.fyi>

* Fix imports

* Remove accidental line

* Re-add mustCallSuper on onGameResize
2021-07-29 14:23:37 +02:00

28 lines
787 B
Dart

import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flame/parallax.dart';
class ComponentParallaxGame extends BaseGame {
@override
Future<void> onLoad() async {
add(MyParallaxComponent());
}
}
class MyParallaxComponent extends ParallaxComponent<ComponentParallaxGame> {
@override
Future<void> onLoad() async {
parallax = await gameRef.loadParallax(
[
ParallaxImageData('parallax/bg.png'),
ParallaxImageData('parallax/mountain-far.png'),
ParallaxImageData('parallax/mountains.png'),
ParallaxImageData('parallax/trees.png'),
ParallaxImageData('parallax/foreground-trees.png'),
],
baseVelocity: Vector2(20, 0),
velocityMultiplierDelta: Vector2(1.8, 1.0),
);
}
}