mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 08:56:01 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
		
			781 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			781 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flame/components.dart';
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame/parallax.dart';
 | |
| 
 | |
| class BasicParallaxExample extends FlameGame {
 | |
|   static const String description = '''
 | |
|     Shows the simplest way to use a fullscreen `ParallaxComponent`.
 | |
|   ''';
 | |
| 
 | |
|   final _imageNames = [
 | |
|     ParallaxImageData('parallax/bg.png'),
 | |
|     ParallaxImageData('parallax/mountain-far.png'),
 | |
|     ParallaxImageData('parallax/mountains.png'),
 | |
|     ParallaxImageData('parallax/trees.png'),
 | |
|     ParallaxImageData('parallax/foreground-trees.png'),
 | |
|   ];
 | |
| 
 | |
|   @override
 | |
|   Future<void> onLoad() async {
 | |
|     final parallax = await loadParallaxComponent(
 | |
|       _imageNames,
 | |
|       baseVelocity: Vector2(20, 0),
 | |
|       velocityMultiplierDelta: Vector2(1.8, 1.0),
 | |
|     );
 | |
|     add(parallax);
 | |
|   }
 | |
| }
 | 
