mirror of https://github.com/flutter/pinball.git
commit
b3230f3aa4
@ -1,10 +1,11 @@
|
||||
library pinball_flame;
|
||||
|
||||
export 'src/behaviors/behaviors.dart';
|
||||
export 'src/canvas/canvas.dart';
|
||||
export 'src/component_controller.dart';
|
||||
export 'src/contact_behavior.dart';
|
||||
export 'src/flame_provider.dart';
|
||||
export 'src/keyboard_input_controller.dart';
|
||||
export 'src/layer.dart';
|
||||
export 'src/parent_is_a.dart';
|
||||
export 'src/pinball_forge2d_game.dart';
|
||||
export 'src/sprite_animation.dart';
|
||||
|
@ -0,0 +1,3 @@
|
||||
export 'contact_behavior.dart';
|
||||
export 'layer_contact_behavior.dart';
|
||||
export 'z_index_contact_behavior.dart';
|
@ -0,0 +1,20 @@
|
||||
import 'package:flame_forge2d/flame_forge2d.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
|
||||
/// {@template layer_contact_behavior}
|
||||
/// Switches the [Layer] of any [Layered] body that contacts with it.
|
||||
/// {@endtemplate}
|
||||
class LayerContactBehavior extends ContactBehavior<BodyComponent> {
|
||||
/// {@macro layer_contact_behavior}
|
||||
LayerContactBehavior({required Layer layer}) : _layer = layer;
|
||||
|
||||
final Layer _layer;
|
||||
|
||||
@override
|
||||
void beginContact(Object other, Contact contact) {
|
||||
super.beginContact(other, contact);
|
||||
if (other is! Layered) return;
|
||||
if (other.layer == _layer) return;
|
||||
other.layer = _layer;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
import 'package:flame_forge2d/flame_forge2d.dart';
|
||||
import 'package:pinball_flame/pinball_flame.dart';
|
||||
|
||||
/// {@template layer_contact_behavior}
|
||||
/// Switches the z-index of any [ZIndex] body that contacts with it.
|
||||
/// {@endtemplate}
|
||||
class ZIndexContactBehavior extends ContactBehavior<BodyComponent> {
|
||||
/// {@macro layer_contact_behavior}
|
||||
ZIndexContactBehavior({required int zIndex}) : _zIndex = zIndex;
|
||||
|
||||
final int _zIndex;
|
||||
|
||||
@override
|
||||
void beginContact(Object other, Contact contact) {
|
||||
super.beginContact(other, contact);
|
||||
if (other is! ZIndex) return;
|
||||
if (other.zIndex == _zIndex) return;
|
||||
other.zIndex = _zIndex;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue