mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 17:06:50 +08:00 
			
		
		
		
	 55aea41788
			
		
	
	55aea41788
	
	
	
		
			
			* Adding animation support to parallax * Solving workaround * Fixing image composition add assert * adding docs, linting and a better example * lint * Apply suggestions from code review Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net> * Update examples/lib/stories/parallax/sandbox_layer.dart * Update doc/components.md * Update examples/lib/stories/parallax/sandbox_layer.dart Co-authored-by: Luan Nico <luanpotter27@gmail.com> * Update examples/lib/stories/parallax/animation.dart * formating * Update .min_coverage Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net> Co-authored-by: Luan Nico <luanpotter27@gmail.com>
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flame/components.dart';
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame/parallax.dart';
 | |
| import 'package:flame/extensions.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| 
 | |
| /// 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
 | |
| /// FCS is only used when you extend BaseGame, not Game,
 | |
| /// like we do in this example.
 | |
| class NoFCSParallaxGame extends Game {
 | |
|   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);
 | |
|   }
 | |
| }
 |