mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-01 01:18:38 +08:00 
			
		
		
		
	 8f7c773f82
			
		
	
	8f7c773f82
	
	
	
		
			
			* Non-fullscreen ParallaxComponent * Updated examples with no size needed * Formatting * Add docs for fullscreen parallax * Fix formatting * Remove need of nullable size * Add basic parallax sizing test * Fix formatting * Remove unused imports * Info text for the parallax examples
		
			
				
	
	
		
			29 lines
		
	
	
		
			712 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			712 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
 | |
|     with HasGameRef<ComponentParallaxGame> {
 | |
|   @override
 | |
|   Future<void> onLoad() async {
 | |
|     parallax = await gameRef.loadParallax(
 | |
|       [
 | |
|         'parallax/bg.png',
 | |
|         'parallax/mountain-far.png',
 | |
|         'parallax/mountains.png',
 | |
|         'parallax/trees.png',
 | |
|         'parallax/foreground-trees.png',
 | |
|       ],
 | |
|       baseVelocity: Vector2(20, 0),
 | |
|       velocityMultiplierDelta: Vector2(1.8, 1.0),
 | |
|     );
 | |
|   }
 | |
| }
 |