After upgrading from Flame 1.0.0 to 1.3.0, my project stopped building with errors like so:
Error: Type 'HasHitboxes' not found.
package:project/…/sprite_components/player_component.dart:14
with HasGameRef, HasHitboxes, Collidable
The errors are related only to HitBoxes and Collidables, in that they are not found, I'm suspecting something needs importing in Flame 1.3.0.
These are my imports:
import 'package:flame/components.dart';
import 'package:flame/geometry.dart';
import 'package:flame/input.dart';
import 'package:flame/sprite.dart';
I tried:
flutter pub cache clean
flutter pub get
But no luck, is there anything else that needs doing?
P.S. If I downgrade back to 1.0.0, everything works fine.
HasHitboxes
and Collidable
aren't used anymore.
Hitboxes are now a first class component in Flame, so you just have to add the hitboxes directly to the component with component.add
. If you want to listen for collisions with those hitboxes you have to add the CollisionCallbacks
mixin to the component and the HasCollisionDetection
to the game.
https://docs.flame-engine.org/1.3.0/flame/collision_detection.html