mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 08:56:01 +08:00 
			
		
		
		
	 ff3d91075c
			
		
	
	ff3d91075c
	
	
	
		
			
			The Parallax already supported filter quality, but the loader methods were missing parameters for it to be passed to the loaded instances, making it impossible (unless manually loading) to set a filter quality in a parallax. By setting a filter quality to none (which on flutter means that the next neighbour algorithm will be user) on pixel art sprites we can keep the crisp look that that style of art demands.
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:ui';
 | |
| 
 | |
| import 'package:flame/extensions.dart';
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame/parallax.dart';
 | |
| 
 | |
| class NoFCSParallaxExample extends Game {
 | |
|   static const String description = '''
 | |
|     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.\n
 | |
|     FCS is only used when you extend FlameGame, not when you only use the Game
 | |
|     mixin, like we do in this example.
 | |
|   ''';
 | |
| 
 | |
|   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),
 | |
|       filterQuality: FilterQuality.none,
 | |
|     );
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void update(double dt) {
 | |
|     parallax.update(dt);
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void render(Canvas canvas) {
 | |
|     parallax.render(canvas);
 | |
|   }
 | |
| }
 |