mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 17:06:50 +08:00 
			
		
		
		
	 7e4bc1464e
			
		
	
	7e4bc1464e
	
	
	
		
			
			* Fix parallax fullscreen bug when game is resized * Test Signed-off-by: Lukas Klingsbo <me@lukas.fyi> * Fix imports * Remove accidental line * Re-add mustCallSuper on onGameResize
		
			
				
	
	
		
			28 lines
		
	
	
		
			787 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			787 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<ComponentParallaxGame> {
 | |
|   @override
 | |
|   Future<void> onLoad() async {
 | |
|     parallax = await gameRef.loadParallax(
 | |
|       [
 | |
|         ParallaxImageData('parallax/bg.png'),
 | |
|         ParallaxImageData('parallax/mountain-far.png'),
 | |
|         ParallaxImageData('parallax/mountains.png'),
 | |
|         ParallaxImageData('parallax/trees.png'),
 | |
|         ParallaxImageData('parallax/foreground-trees.png'),
 | |
|       ],
 | |
|       baseVelocity: Vector2(20, 0),
 | |
|       velocityMultiplierDelta: Vector2(1.8, 1.0),
 | |
|     );
 | |
|   }
 | |
| }
 |