mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 17:06:50 +08:00 
			
		
		
		
	 e4281d6471
			
		
	
	e4281d6471
	
	
	
		
			
			* Add onCollisionEnd for HitboxShape and Collidable * Add tests for collision callbacks * Detect multiple collsions with same collidable in test * Remove unused import * Break out duplicated code * Fix formatting * Use correct hash set * Update examples/lib/stories/collision_detection/multiple_shapes.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Update examples/lib/stories/collision_detection/multiple_shapes.dart Co-authored-by: Erick <erickzanardoo@gmail.com> * Use hashValues instead of _combineHashCodes * hashValues is order dependent so we need to sort the objects first * Add section about onCollisionEnd * Fix missed hashValues * Use xor instead of hashValues * Update examples/lib/stories/collision_detection/collision_detection.dart Co-authored-by: Luan Nico <luanpotter27@gmail.com> Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Luan Nico <luanpotter27@gmail.com>
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:dashbook/dashbook.dart';
 | |
| import 'package:flame/game.dart';
 | |
| 
 | |
| import '../../commons/commons.dart';
 | |
| import 'circles.dart';
 | |
| import 'multiple_shapes.dart';
 | |
| import 'only_shapes.dart';
 | |
| 
 | |
| const basicInfo = '''
 | |
| An example with many hitboxes that move around on the screen and during
 | |
| collisions they change color depending on what it is that they have collided
 | |
| with. 
 | |
| 
 | |
| The snowman, the component built with three circles on top of each other, works
 | |
| a little bit differently than the other components to show that you can have
 | |
| multiple hitboxes within one component.
 | |
| 
 | |
| On this example, you can "throw" the components by dragging them quickly in any
 | |
| direction.
 | |
| ''';
 | |
| 
 | |
| void addCollisionDetectionStories(Dashbook dashbook) {
 | |
|   dashbook.storiesOf('Collision Detection')
 | |
|     ..add(
 | |
|       'Circles',
 | |
|       (_) => GameWidget(game: Circles()),
 | |
|       codeLink: baseLink('collision_detection/circles.dart'),
 | |
|     )
 | |
|     ..add(
 | |
|       'Multiple shapes',
 | |
|       (_) => GameWidget(game: MultipleShapes()),
 | |
|       codeLink: baseLink('collision_detection/multiple_shapes.dart'),
 | |
|       info: basicInfo,
 | |
|     )
 | |
|     ..add(
 | |
|       'Shapes without components',
 | |
|       (_) => GameWidget(game: OnlyShapes()),
 | |
|       codeLink: baseLink('collision_detection/only_shapes.dart'),
 | |
|     );
 | |
| }
 |