mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-30 16:36:57 +08:00
* Animations, CameraAndViewport, CollisionDetection and Components unified * Added descriptions to effects * Rename input games * Unify input stories * Add info to parallax section * Added descriptions to the rendering examples * Add descriptions to the sprites directory * Fix utils and rendering section * Add descriptions to the widgets section * Delete directory that rebase brought back * Unify game names * Added some styleguide docs for examples * Fix analyze issues * All files should have _example as suffix * Made the FollowComponentExample a bit easier to understand * Change priority of ember
50 lines
1.2 KiB
Dart
50 lines
1.2 KiB
Dart
import 'package:flame/components.dart';
|
|
import 'package:flame/game.dart';
|
|
import 'package:flame/parallax.dart';
|
|
import 'package:flutter/painting.dart';
|
|
|
|
class AnimationParallaxExample extends FlameGame {
|
|
static const String description = '''
|
|
Shows how to use animations in a `ParallaxComponent`.
|
|
''';
|
|
|
|
@override
|
|
Future<void> onLoad() async {
|
|
await super.onLoad();
|
|
final cityLayer = await loadParallaxLayer(
|
|
ParallaxImageData('parallax/city.png'),
|
|
);
|
|
|
|
final rainLayer = await loadParallaxLayer(
|
|
ParallaxAnimationData(
|
|
'parallax/rain.png',
|
|
SpriteAnimationData.sequenced(
|
|
amount: 4,
|
|
stepTime: 0.3,
|
|
textureSize: Vector2(80, 160),
|
|
),
|
|
),
|
|
velocityMultiplier: Vector2(2, 0),
|
|
);
|
|
|
|
final cloudsLayer = await loadParallaxLayer(
|
|
ParallaxImageData('parallax/heavy_clouded.png'),
|
|
velocityMultiplier: Vector2(4, 0),
|
|
fill: LayerFill.none,
|
|
alignment: Alignment.topLeft,
|
|
);
|
|
|
|
final parallax = Parallax(
|
|
[
|
|
cityLayer,
|
|
rainLayer,
|
|
cloudsLayer,
|
|
],
|
|
baseVelocity: Vector2(20, 0),
|
|
);
|
|
|
|
final parallaxComponent = ParallaxComponent(parallax: parallax);
|
|
add(parallaxComponent);
|
|
}
|
|
}
|