MultiGridLevel constructor
MultiGridLevel({
- required Game game,
- required Message title,
- required List<
MultiGridLevelRow> rows, - void onCancel()?,
- int? verticalPosition,
- int? horizontalPosition,
- GameControllerAxis leftRightAxis = GameControllerAxis.leftx,
- ScanCode leftScanCode = ScanCode.left,
- ScanCode rightScanCode = ScanCode.right,
- GameControllerAxis upDownAxis = GameControllerAxis.lefty,
- ScanCode upScanCode = ScanCode.up,
- ScanCode downScanCode = ScanCode.down,
- GameControllerAxis activateAxis = GameControllerAxis.triggerright,
- ScanCode activateScanCode = ScanCode.space,
- GameControllerAxis cancelAxis = GameControllerAxis.triggerleft,
- ScanCode cancelScanCode = ScanCode.escape,
- double axisSensitivity = 0.5,
- int axisInterval = 400,
- AssetReference? music,
- List<
Ambiance> ? ambiances, - List<
RandomSound> ? randomSounds, - 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();
}