MultiGridLevel constructor

MultiGridLevel({
  1. required Game game,
  2. required Message title,
  3. required List<MultiGridLevelRow> rows,
  4. void onCancel()?,
  5. int? verticalPosition,
  6. int? horizontalPosition,
  7. GameControllerAxis leftRightAxis = GameControllerAxis.leftx,
  8. ScanCode leftScanCode = ScanCode.left,
  9. ScanCode rightScanCode = ScanCode.right,
  10. GameControllerAxis upDownAxis = GameControllerAxis.lefty,
  11. ScanCode upScanCode = ScanCode.up,
  12. ScanCode downScanCode = ScanCode.down,
  13. GameControllerAxis activateAxis = GameControllerAxis.triggerright,
  14. ScanCode activateScanCode = ScanCode.space,
  15. GameControllerAxis cancelAxis = GameControllerAxis.triggerleft,
  16. ScanCode cancelScanCode = ScanCode.escape,
  17. double axisSensitivity = 0.5,
  18. int axisInterval = 400,
  19. AssetReference? music,
  20. List<Ambiance>? ambiances,
  21. List<RandomSound>? randomSounds,
  22. Map<String, Command>? commands,
})

Create an instance.

Implementation

MultiGridLevel({
  required super.game,
  required this.title,
  required this.rows,
  this.onCancel,
  final int? verticalPosition,
  final int? horizontalPosition,
  final GameControllerAxis leftRightAxis = GameControllerAxis.leftx,
  this.leftScanCode = ScanCode.left,
  this.rightScanCode = ScanCode.right,
  final GameControllerAxis upDownAxis = GameControllerAxis.lefty,
  this.upScanCode = ScanCode.up,
  this.downScanCode = ScanCode.down,
  final GameControllerAxis activateAxis = GameControllerAxis.triggerright,
  this.activateScanCode = ScanCode.space,
  final GameControllerAxis cancelAxis = GameControllerAxis.triggerleft,
  this.cancelScanCode = ScanCode.escape,
  final double axisSensitivity = 0.5,
  final int axisInterval = 400,
  super.music,
  super.ambiances,
  super.randomSounds,
  super.commands,
})  : axisDispatcher = ControllerAxisDispatcher(
        {},
        axisSensitivity: axisSensitivity,
        functionInterval: axisInterval,
      ),
      _horizontalPositions = [],
      _verticalPosition = verticalPosition {
  if (verticalPosition != null) {
    while (_horizontalPositions.length <= verticalPosition) {
      _horizontalPositions.add(null);
    }
    _horizontalPositions[verticalPosition] = horizontalPosition;
  }
  axisDispatcher.axes[leftRightAxis] = (final value) {
    if (value < 0) {
      left();
    } else {
      right();
    }
  };
  axisDispatcher.axes[upDownAxis] = (final value) {
    if (value > 0) {
      down();
    } else {
      up();
    }
  };
  axisDispatcher.axes[activateAxis] = (final value) => activate();
  axisDispatcher.axes[cancelAxis] = (final value) => cancel();
}