mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 08:56:01 +08:00 
			
		
		
		
	 cd7a0bbb65
			
		
	
	cd7a0bbb65
	
	
	
		
			
			* `ShapeComponent` changes size, position and angle of underlying Shape * Added description to ShapeComponent * Fix test * Update packages/flame/lib/src/components/shape_component.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Add absoluteScale and absoluteAngle to PositionComponent * Refactor ShapeComponent * Should be scaled by total scale, not scaled size * Premature optimization for creation for objects in Polygon * Use path for default Polygon constructor * Do not sync component and hitbox shape * Fix analyze issue * Add example for flipping with collision detection * Don't use absoluteScale * Fix examples * Fix examples * Doesn't need super.render * Fix Circle dartdoc * Update changelog * Update names of vertices caches in Polygon * Update text docs * Revert "Update text docs" This reverts commit 73a68a465d76eb0eb50bb3753e57b2f4e3b5a7f4. * Fix examples * ShapeComponents docs * Move example games to the top * Fix dartdoc comment about polygon vertex relation * Fix order of polygon vertices in dartdoc * Fix anchor for PolygonComponent.fromPoints * Add test with ancestors * Update doc/components.md Co-authored-by: Pasha Stetsenko <stpasha@google.com> * Update doc/components.md Co-authored-by: Erick <erickzanardoo@gmail.com> * Rename example classes * Fix linting issues in examples * Don't use px * Use isTrue and isFalse * Update doc/components.md Co-authored-by: Erick <erickzanardoo@gmail.com> * Fixed comments on PR Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Pasha Stetsenko <stpasha@google.com>
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.4 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';
 | |
| 
 | |
| 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.random(rng));
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| class _RandomCircle extends CircleComponent with Tappable {
 | |
|   _RandomCircle(double radius, {Vector2? position, Paint? paint})
 | |
|       : super(radius: radius, position: position, paint: paint);
 | |
| 
 | |
|   factory _RandomCircle.random(Random rng) {
 | |
|     final radius = rng.nextDouble() * 30 + 10;
 | |
|     final position = Vector2(
 | |
|       rng.nextDouble() * 320 + 40,
 | |
|       rng.nextDouble() * 520 + 40,
 | |
|     );
 | |
|     final paint = Paint()
 | |
|       ..color = Colors.primaries[rng.nextInt(Colors.primaries.length)];
 | |
|     return _RandomCircle(radius, position: position, paint: paint);
 | |
|   }
 | |
| 
 | |
|   @override
 | |
|   bool onTapDown(TapDownInfo info) {
 | |
|     add(RemoveEffect(delay: 0.5));
 | |
|     return false;
 | |
|   }
 | |
| }
 |