mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-01 01:18:38 +08:00 
			
		
		
		
	 5c47d7f6d7
			
		
	
	5c47d7f6d7
	
	
	
		
			
			* Added Component.childrenFactory * fix some of the lint warnings * more lint warnings * remove changelog entry * more analyzer warnings * one more warning * one more warning * remove more unused imports * fix more warnings * another warning * one more warning * a lot more warnings * some more warnings * fix warnings in flame_svg * fix warnings in flame_bloc * Remove OrderedSet override feature * Remove testRandom change * Remove unnecessary type checks * Re-remove deprecated argument in random_test Co-authored-by: Pasha Stetsenko <stpasha@google.com>
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flame/components.dart';
 | |
| import 'package:flame/effects.dart';
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame/input.dart';
 | |
| import 'package:flame/palette.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| 
 | |
| class ScaleEffectExample extends FlameGame with TapDetector {
 | |
|   static const String description = '''
 | |
|     The `ScaleEffect` scales up the canvas before drawing the components and its
 | |
|     children.
 | |
|     In this example you can tap the screen and the component will scale up or
 | |
|     down, depending on its current state.
 | |
|   ''';
 | |
| 
 | |
|   late RectangleComponent square;
 | |
|   bool grow = true;
 | |
| 
 | |
|   @override
 | |
|   Future<void> onLoad() async {
 | |
|     await super.onLoad();
 | |
|     square = RectangleComponent.square(
 | |
|       size: 100,
 | |
|       position: Vector2.all(200),
 | |
|       paint: BasicPalette.white.paint()..style = PaintingStyle.stroke,
 | |
|     );
 | |
|     final childSquare = RectangleComponent.square(
 | |
|       position: Vector2.all(70),
 | |
|       size: 20,
 | |
|     );
 | |
|     square.add(childSquare);
 | |
|     add(square);
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   void onTap() {
 | |
|     final s = grow ? 3.0 : 1.0;
 | |
| 
 | |
|     grow = !grow;
 | |
| 
 | |
|     square.add(
 | |
|       ScaleEffect.to(
 | |
|         Vector2.all(s),
 | |
|         EffectController(
 | |
|           duration: 1.5,
 | |
|           curve: Curves.bounceInOut,
 | |
|         ),
 | |
|       ),
 | |
|     );
 | |
|   }
 | |
| }
 |