diff --git a/lib/presentation/home/home.dart b/lib/presentation/home/home.dart index bbc100a..57dd6b9 100644 --- a/lib/presentation/home/home.dart +++ b/lib/presentation/home/home.dart @@ -1,4 +1,5 @@ import 'package:flame/components.dart'; +import 'package:flame/flame.dart'; import 'package:flutter/material.dart'; import 'package:fruit_cutting_game/common/widgets/button/rounded_button.dart'; import 'package:fruit_cutting_game/common/widgets/text/simple_center_text.dart'; @@ -23,10 +24,50 @@ class HomePage extends Component with HasGameReference { late final InteractiveButtonComponent _gameModeComponent; + // warning widget + late final SpriteComponent _gifWidget; + late final TextComponent _textComponent; + + bool isAddAll = false; + bool isAddWarning = false; + @override void onLoad() async { super.onLoad(); + if (game.size.y < 400 || game.size.x < 400 || game.size.x < game.size.y) { + final warningGifImage = await Flame.images.load(AppImages.banana); + addAll( + [ + _textComponent = TextComponent( + text: 'Use a computer monitor\nfor the best experience', + textRenderer: TextPaint( + style: const TextStyle( + fontSize: 22, + color: AppColors.white, + fontFamily: 'Insan', + letterSpacing: 2.0, + fontWeight: FontWeight.bold, + ), + ), + position: Vector2(game.size.x / 2, game.size.y / 2 + 70), + anchor: Anchor.center, + ), + _gifWidget = SpriteComponent.fromImage( + warningGifImage, + size: Vector2(120, 120), + ) + ..position = Vector2(game.size.x / 2, game.size.y / 2 - 50) + ..anchor = Anchor.center, + ], + ); + + isAddWarning = true; + } else { + initComponent(); + } + } + void initComponent() { final textTitlePaint = TextPaint( style: const TextStyle( fontSize: 26, @@ -104,21 +145,27 @@ class HomePage extends Component with HasGameReference { )..anchor = Anchor.bottomRight, ], ); + + isAddAll = true; } @override void onGameResize(Vector2 size) { super.onGameResize(size); + if (isAddAll) { + // button in center of page + _button.position = size / 2; - // button in center of page - _button.position = size / 2; - - _tutorialRuleScore1Component.position = Vector2(game.size.x / 2, game.size.y - game.size.y / 3.9); - _tutorialRuleScore2Component.position = Vector2(game.size.x / 2, game.size.y - game.size.y / 5.1); - _tutorialRuleLose1Component.position = Vector2(game.size.x / 2, game.size.y / 5.1); - _tutorialRuleLose2Component.position = Vector2(game.size.x / 2, game.size.y / 3.9); + _tutorialRuleScore1Component.position = Vector2(game.size.x / 2, game.size.y - game.size.y / 3.9); + _tutorialRuleScore2Component.position = Vector2(game.size.x / 2, game.size.y - game.size.y / 5.1); + _tutorialRuleLose1Component.position = Vector2(game.size.x / 2, game.size.y / 5.1); + _tutorialRuleLose2Component.position = Vector2(game.size.x / 2, game.size.y / 3.9); - _bombTextComponent.position = Vector2(game.size.x - 45, 10); - _gameModeComponent.position = Vector2(game.size.x - 50, game.size.y - 50); + _bombTextComponent.position = Vector2(game.size.x - 45, 10); + _gameModeComponent.position = Vector2(game.size.x - 50, game.size.y - 50); + } else if (isAddWarning) { + _textComponent.position = Vector2(game.size.x / 2, game.size.y / 2 + 70); + _gifWidget.position = Vector2(game.size.x / 2, game.size.y / 2 - 50); + } } } diff --git a/web/index.html b/web/index.html index 8888c29..872ba85 100644 --- a/web/index.html +++ b/web/index.html @@ -46,42 +46,15 @@ Loading...