Files
flame/examples/lib/stories/parallax/no_fcs_parallax_example.dart
Pasha Stetsenko 5225a4ebd5 refactor: Game is now a class, not a mixin (#1751)
This simple refactor allows us to write class MyGame extends Game, instead of a more awkward class MyGame with Game. However, using ... with Game still continues to work, so no changes necessary for the users.
2022-06-25 21:32:32 +00:00

42 lines
1.1 KiB
Dart

import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flame/parallax.dart';
class NoFCSParallaxExample extends Game {
static const String description = '''
This examples serves to test the Parallax feature outside of the Flame
Component System (FCS), use the other files in this folder for examples on
how to use parallax with FCS.\n
FCS is only used when you extend FlameGame, not when you only use the Game
mixin, like we do in this example.
''';
late Parallax parallax;
@override
Future<void> onLoad() async {
parallax = await loadParallax(
[
ParallaxImageData('parallax/bg.png'),
ParallaxImageData('parallax/mountain-far.png'),
ParallaxImageData('parallax/mountains.png'),
ParallaxImageData('parallax/trees.png'),
ParallaxImageData('parallax/foreground-trees.png'),
],
size: size,
baseVelocity: Vector2(20, 0),
velocityMultiplierDelta: Vector2(1.8, 1.0),
);
}
@override
void update(double dt) {
parallax.update(dt);
}
@override
void render(Canvas canvas) {
parallax.render(canvas);
}
}