Skip to content

Latest commit

 

History

History

flame_cli

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

flame

A command line tool for inspecting and controlling running Flame games.


flame_cli

The flame command inspects and controls a Flame game that is running in debug mode, without having to open the DevTools. This makes it possible for scripts and AI coding agents to, for example, see what the game currently looks like.

Installation

dart pub global activate flame_cli

Usage

Create a new game, like flutter create but from a Flame template and with the Flame packages set up:

flame create my_game
cd my_game

Start your game with flame run from your project directory. It takes the same arguments as flutter run, and lets the other commands find the game:

flame run -d macos

Then render the whole game to a PNG image:

flame snapshot --output snapshot.png

List the components together with their ids and attributes, and render a single component:

flame tree
flame snapshot --component 220731871

Annotate the snapshot with the box, id and type of every visible component, so that what is seen in the image can be matched with the ids, and keep the image within the size limits of AI models:

flame snapshot --annotate --filter 'player|enemy' --max-size 1024

Hot reload or restart the game after changing the code, also merging changes to constructors and onLoad methods into the live components while they keep their state, read its output, open the Flutter DevTools with the Flame tab for the game, check whether it is running and stop it:

flame reload
flame reload --merge
flame logs
flame devtools
flame status
flame stop

Pause the game, step it forward a number of frames, inspect and change components, turn on the debug rendering and show or hide overlays:

flame pause
flame step --frames 60
flame inspect 220731871
flame set 220731871 --position 100,200
flame debug on
flame overlay show PauseMenu

A running game is tied to its project, so games from different projects never interfere. Several instances of one project can run at once, for example on two devices: the commands go to the one started last, and any other one can be addressed with the URI and the port that flame run prints, through --uri and, for reload, restart, stop and status, --port. The same --uri option reaches a game that was started in another way, with the Dart VM Service URI that flutter run prints.

Play the game by sending taps, drags and key presses, to a position or to a component from the tree, wait until something happens in the game, and compare two snapshots:

flame input tap 400,300
flame input tap --component 220731871
flame input drag --from-component 220731871 600,300
flame input key space
flame wait overlay GameOver --timeout 5
flame wait component Enemy --gone
flame diff before.png after.png --output diff.png

Pass --json to any command except run to get the result, or the error when it fails, as JSON on the standard output, for use in scripts and by AI coding agents:

flame snapshot --json

Run flame --help for all the commands and options, and see the documentation for more information.