mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 08:56:01 +08:00 
			
		
		
		
	 d9984c7bda
			
		
	
	d9984c7bda
	
	
	
		
			
			* Added FlameAnimationController class * Added MainAnimationController class * Update doc comments * formatting * rename MainAnimationController * Added tests for StandardAnimationController * Added more tests * comment * Added changelog note * Export StandardAnimationController * formatting * Use a default for 'curve' parameter * rename onsetDelay -> startDelay * Added Transofm2DEffect * Added EffectComponent * Added .transform getter * formatting * Rename EffectComponent -> Effect * Add documentation for the Effect class * minor * Added a test for Effect class * Adding tests for removeOnFinish * Adding tests for onStart and onFinish * Also check the effect after reset * Fix-up merge * formatting * added doc-comments * changelog note * Added test for transform2DEffect * Adjusted comments * Make PositionComponent._transform public * change changelog * Added SimpleEffectController * Added DestroyEffect * Changelog note * Rename DestroyEffect -> RemoveEffect * Added example for RemoveEffect * flutter format * Move description of the RemoveEffectExample game * move the description again * minor
		
			
				
	
	
		
			42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:math';
 | |
| 
 | |
| import 'package:flame/components.dart';
 | |
| import 'package:flame/game.dart';
 | |
| import 'package:flame/input.dart';
 | |
| import 'package:flame/src/effects2/remove_effect.dart'; // ignore: implementation_imports
 | |
| import 'package:flutter/material.dart';
 | |
| import '../../commons/circle_component.dart';
 | |
| 
 | |
| class RemoveEffectExample extends FlameGame with HasTappableComponents {
 | |
|   static const description = '''
 | |
|     Click on any circle to apply a RemoveEffect, which will make the circle
 | |
|     disappear after a 0.5 second delay.
 | |
|   ''';
 | |
| 
 | |
|   @override
 | |
|   void onMount() {
 | |
|     super.onMount();
 | |
|     camera.viewport = FixedResolutionViewport(Vector2(400, 600));
 | |
|     final rng = Random();
 | |
|     for (var i = 0; i < 20; i++) {
 | |
|       add(_RandomCircle(rng));
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| class _RandomCircle extends CircleComponent with Tappable {
 | |
|   _RandomCircle(Random rng) : super(radius: rng.nextDouble() * 30 + 10) {
 | |
|     position.setValues(
 | |
|       rng.nextDouble() * 320 + 40,
 | |
|       rng.nextDouble() * 520 + 40,
 | |
|     );
 | |
|     paint.color = Colors.primaries[rng.nextInt(Colors.primaries.length)];
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   bool onTapDown(TapDownInfo info) {
 | |
|     add(RemoveEffect(delay: 0.5));
 | |
|     return false;
 | |
|   }
 | |
| }
 |