Mixin useful to detect if any object came into contact but without blocking its passage. Example: Fire on the ground, spikes, etc. Things that the character or enemy can go through and take damage or activate any other type of behavior.
class Spikes extends GameDecoration with Sensor {
MyCustomDecoration(Position position)
: super.withAnimation(
Future<SpriteAnimation>(),
size: Vector2(32,32),
position: position,
){
// call this method to configure sensor area.
setupSensorArea(
areaSensor: [
CollisionArea.rectangle(
size: Vector2(32,32),
),
]
);
}
@override
void onContact(GameComponent component) {
// do anything with the Component that take contact
}
}