mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-31 00:48:47 +08:00
* Adding animation support to parallax * Solving workaround * Fixing image composition add assert * adding docs, linting and a better example * lint * Apply suggestions from code review Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net> * Update examples/lib/stories/parallax/sandbox_layer.dart * Update doc/components.md * Update examples/lib/stories/parallax/sandbox_layer.dart Co-authored-by: Luan Nico <luanpotter27@gmail.com> * Update examples/lib/stories/parallax/animation.dart * formating * Update .min_coverage Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net> Co-authored-by: Luan Nico <luanpotter27@gmail.com>
24 lines
709 B
Dart
24 lines
709 B
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flame/parallax.dart';
|
|
|
|
class SmallParallaxGame extends BaseGame {
|
|
@override
|
|
Future<void> onLoad() async {
|
|
final component = await loadParallaxComponent(
|
|
[
|
|
ParallaxImageData('parallax/bg.png'),
|
|
ParallaxImageData('parallax/mountain-far.png'),
|
|
ParallaxImageData('parallax/mountains.png'),
|
|
ParallaxImageData('parallax/trees.png'),
|
|
ParallaxImageData('parallax/foreground-trees.png'),
|
|
],
|
|
size: Vector2.all(200),
|
|
baseVelocity: Vector2(20, 0),
|
|
velocityMultiplierDelta: Vector2(1.8, 1.0),
|
|
)
|
|
..position = size / 2;
|
|
add(component);
|
|
}
|
|
}
|