|
|
@ -1,5 +1,3 @@
|
|
|
|
import 'dart:math';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flame/components.dart';
|
|
|
|
import 'package:flame/components.dart';
|
|
|
|
import 'package:flame/game.dart';
|
|
|
|
import 'package:flame/game.dart';
|
|
|
|
import 'package:flame_bloc/flame_bloc.dart';
|
|
|
|
import 'package:flame_bloc/flame_bloc.dart';
|
|
|
@ -43,30 +41,25 @@ class CameraFocusingBehavior extends Component
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void onGameResize(Vector2 size) {
|
|
|
|
void onGameResize(Vector2 size) {
|
|
|
|
super.onGameResize(size);
|
|
|
|
super.onGameResize(size);
|
|
|
|
if (size == _previousSize) {
|
|
|
|
if (size == _previousSize) return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_previousSize.setFrom(size);
|
|
|
|
_previousSize.setFrom(size);
|
|
|
|
|
|
|
|
|
|
|
|
final maxWidth = size.x / 90;
|
|
|
|
_foci.addAll(
|
|
|
|
final maxHeight = size.y / 160;
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
final scale = min(maxHeight, maxWidth);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_foci.addAll({
|
|
|
|
|
|
|
|
GameStatus.waiting: _FocusData(
|
|
|
|
GameStatus.waiting: _FocusData(
|
|
|
|
zoom: scale + (maxWidth > maxHeight ? 0.3 : -0.5),
|
|
|
|
zoom: size.y / 175,
|
|
|
|
position: Vector2(0, -112),
|
|
|
|
position: _foci[GameStatus.waiting]?.position ?? Vector2(0, -112),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GameStatus.playing: _FocusData(
|
|
|
|
GameStatus.playing: _FocusData(
|
|
|
|
zoom: scale + (maxWidth > maxHeight ? 0.5 : -0.2),
|
|
|
|
zoom: size.y / 165,
|
|
|
|
position: Vector2(0, -7.8),
|
|
|
|
position: _foci[GameStatus.playing]?.position ?? Vector2(0, -7.8),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GameStatus.gameOver: _FocusData(
|
|
|
|
GameStatus.gameOver: _FocusData(
|
|
|
|
zoom: scale + (maxWidth > maxHeight ? 2.8 : 3.3),
|
|
|
|
zoom: size.y / 100,
|
|
|
|
position: Vector2(0, -111),
|
|
|
|
position: _foci[GameStatus.gameOver]?.position ?? Vector2(0, -111),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (_activeFocus != null) {
|
|
|
|
if (_activeFocus != null) {
|
|
|
|
_snap(_activeFocus!);
|
|
|
|
_snap(_activeFocus!);
|
|
|
|