mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 17:06:50 +08:00 
			
		
		
		
	* wip o lifecycle * Component.add() is no longer async * fix a test * game.ready * fix analyze issues * FcsRoot * fix tests * fix game-in-game example * Merge _addImpl with add() * Move some of the functionality from prepare() into add() * Moved FcsRoot into component.dart and renamed * more doc-comments * dartdocs * Remove addLater in ComponentSet * format * temporarily switch to path dependency in flame_test * restore a test * format * get rid of prepare() in Collidable * eliminate prepare() in Draggable * eradicate prepare() in Hoverable * remove prepare() from Tappable * remove prepare() method and isPrepared flag * remove prepareComponent() from HasCollidables * remove prepareComponent * make flame_bloc depend on latest flame * try to solve flame_bloc dependency graph * fix game resize issue * fix gameresize for zoomed game * do not allow zero size in onGameResize * move onMount() call into add() * use loadingBuilder when size is 0 * ComponentTreeRoot is now in its own file * addToParent() * switch to mount queue * rename isReadyToMount -> isPrepared * make isMounted and isPrepared readonly * minor * print error stacktrace * Component.add() is now async * fix tests * unused import ; * undo irrelevant changes in Component * update tests * tests cleanup * format * expand doc for ComponentTreeRoot * fix analysis error * added tests * update docs * resolve version conflict in pubspec * Apply suggestions from code review Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com> * late final * remount() function * remove mountQueue * simplify ready() * run mount during children queue processing * simplify mounting * rename childrenQueue->childreQueues * merge tryMounting() with remount() * avoid statics in components lifecycle * remove ComponentTreeRoot * remove dead code * added a todo * added docs for SingleGameInstance * Added tests for SingleGameInstance * added SingleGameInstance to the main doc site * Added test for multi-widget games * cleanup * use state variable in Component * remove test as dependency * upgrade mocktail version * upgrade dartdoc version * fix analyzer warnings * mark staticgameinstance as internal * remove ComponentSet.addChild * use log() from dart:developer * undo changes in flame_bloc/pubspec.yaml * redo changes in flame_bloc/pubspec.yaml * fix dependency in flame_test * remove test dependencies * update pubspec files * remove dart_code_metrics from pubspec * fix a test * Added GameTester.makeReady * omit type on class variable when it can be inferred Co-authored-by: Erick <erickzanardoo@gmail.com> Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com> Co-authored-by: Erick <erickzanardoo@gmail.com>
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flame/components.dart';
 | |
| import 'package:flame/game.dart';
 | |
| 
 | |
| import '../input/draggables_example.dart';
 | |
| import 'composability_example.dart';
 | |
| 
 | |
| class GameInGameExample extends FlameGame with HasDraggables {
 | |
|   static const String description = '''
 | |
|     This example shows two games having another game as a parent.
 | |
|     One game contains draggable components and the other is a rotating square
 | |
|     with other square children.
 | |
|     After 5 seconds, one of the components from the game with draggable squares
 | |
|     changes its parent from its original game to the component that is rotating.
 | |
|     After another 5 seconds it changes back to its original parent, and so on.
 | |
|   ''';
 | |
| 
 | |
|   @override
 | |
|   bool debugMode = true;
 | |
|   late final ComposabilityExample composedGame;
 | |
|   late final DraggablesExample draggablesGame;
 | |
| 
 | |
|   @override
 | |
|   Future<void> onLoad() async {
 | |
|     composedGame = ComposabilityExample();
 | |
|     draggablesGame = DraggablesExample(zoom: 1.0);
 | |
|     await add(composedGame);
 | |
|     await add(draggablesGame);
 | |
| 
 | |
|     add(GameChangeTimer());
 | |
|   }
 | |
| }
 | |
| 
 | |
| class GameChangeTimer extends TimerComponent
 | |
|     with HasGameRef<GameInGameExample> {
 | |
|   GameChangeTimer() : super(period: 5, repeat: true);
 | |
| 
 | |
|   @override
 | |
|   void onTick() {
 | |
|     final child = gameRef.draggablesGame.square;
 | |
|     final newParent = child.parent == gameRef.draggablesGame
 | |
|         ? gameRef.composedGame.parentSquare
 | |
|         : gameRef.draggablesGame;
 | |
|     child.changeParent(newParent);
 | |
|   }
 | |
| }
 |