fix: CircleHitbox should properly detect when ray is outside (#3100)

Previously some rays that originated outside of the `CircleHitbox` were
counted as inside, this solves that and adds an example of how to use
the `isInsideHitbox` functionality (thanks to @wurzelsand).


Closes #3063
This commit is contained in:
Lukas Klingsbo
2024-03-26 22:59:29 +01:00
committed by GitHub
parent ed690b3048
commit 8cd9e12319
4 changed files with 186 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import 'package:examples/stories/collision_detection/quadtree_example.dart';
import 'package:examples/stories/collision_detection/raycast_example.dart';
import 'package:examples/stories/collision_detection/raycast_light_example.dart';
import 'package:examples/stories/collision_detection/raycast_max_distance_example.dart';
import 'package:examples/stories/collision_detection/rays_in_shape_example.dart';
import 'package:examples/stories/collision_detection/raytrace_example.dart';
import 'package:flame/game.dart';
import 'package:flutter/widgets.dart';
@ -76,5 +77,11 @@ void addCollisionDetectionStories(Dashbook dashbook) {
codeLink:
baseLink('collision_detection/raycast_max_distance_example.dart'),
info: RaycastMaxDistanceExample.description,
)
..add(
'Ray inside/outside shapes',
(_) => GameWidget(game: RaysInShapeExample()),
codeLink: baseLink('collision_detection/rays_in_shape_example.dart'),
info: RaysInShapeExample.description,
);
}