mirror of
https://github.com/flame-engine/flame.git
synced 2025-10-30 08:27:36 +08:00
onCollisionEnd callbacks for Collidable and HitboxShape (#792)
* 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>
This commit is contained in:
@ -6,6 +6,19 @@ 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(
|
||||
@ -17,6 +30,7 @@ void addCollisionDetectionStories(Dashbook dashbook) {
|
||||
'Multiple shapes',
|
||||
(_) => GameWidget(game: MultipleShapes()),
|
||||
codeLink: baseLink('collision_detection/multiple_shapes.dart'),
|
||||
info: basicInfo,
|
||||
)
|
||||
..add(
|
||||
'Shapes without components',
|
||||
|
||||
Reference in New Issue
Block a user