A Workspace for Flame games.
[!NOTE]
This project is unrelated to the Flame team, it is a personal project that I'm working on to make it easier to create games using Flame. For official support, see flame-engine/Flame Studio
https://github.com/bdlukaa/flame_workspace/assets/45696119/00178d89-aeeb-487c-a262-557258db4fbc
Given the current state of the application, some manual steps are required to run it. The template/
folder contains the necessary arrangements to make it run and interact with the Workspace.
1.
Clone the repository
2.
Run flutter run
in the flame_workspace
folder to start the Workspace
3.
Open the template/
folder from the Workspace
4.
Run
the project to start the Game Preview
flame_workspace The app itself. It is resposible to create, edit, generate code and connect to the server
template A template used when creating a new Flame project. The default folder structure is:
assets/ # Contains the assets of the game
lib/ # Contains the source code of the game
generated/ # Contains the generated code
components/ # Contains the generated code of the components
scenes/ # Contains the generated code of the scenes
properties.dart # Contains the generated code to manipulate components
components/
component_name.dart # A custom component
scenes/
scene_name.dart # A scene
scene_name_script.dart # The script of the scene_name
main.dart # The entry point of the game
game.dart # The game itself
pubspec.yaml # The dependencies of the game
flame_configuration.yaml # Configuration options used by the workspace
For more details, see template/README.md
flame_workspace_core The core package, in which every Flame project must depend on. It contains the necessary code that makes the interaction between the Workspace and the game itself possible.
The Dart Analyzer is used to parse the entire code of the game. The Workspace uses this info to display the available components, scenes and other information about the project.
The Game Preview is the game itself, running on a separate window. The communication between the Workspace and the Game Preview is done using the local http server created by the flame_workspace_core
package, making it possible to edit the components properties from the Workspace itself, without the need to edit the code. See this for more info on how it works.
[!IMPORTANT]
The Game Preview is embedded into the Workspace using flutter_native_view, since Flutter doesn't support Platform Views on Desktop yet (by 11/05/23).
With the analyzed code, the workspace can generate code to allow the interaction between the game and the Workspace. This is necessary because reflection is not supported on Flutter. The generated code is placed in the lib/generated/
folder:
properties.dart
This file is generated by the PropertiesGenerator
and contains functions to manipulate all the components in the project, whether they're built-in Flame components or custom components.
scene_${sceneName}.dart
This file is generated by the SceneGenerator
and contains functions to manipulate the scenes in the project. It creates a mixin with the name Scene${sceneName}
, which every scene must depend on. Don't worry, this is hanlded automatically by the Workspace.
These files are generated every time the files are changed.