-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Blue Fire
committed
Sep 22, 2023
1 parent
040eec3
commit cdf3b75
Showing
617 changed files
with
663,205 additions
and
47,656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 6e18d0ead616f85b547d6266f30e3cc9 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Getting Started | ||
|
||
|
||
## About Flame | ||
|
||
Flame is a modular Flutter game engine that provides a complete set of out-of-the-way solutions for | ||
games. It takes advantage of the powerful infrastructure provided by Flutter but simplifies the code | ||
you need to build your projects. | ||
|
||
It provides you with a simple yet effective game loop implementation, and the necessary | ||
functionalities that you might need in a game. For instance; input, images, sprites, sprite sheets, | ||
animations, collision detection, and a component system that we call Flame Component System (FCS for | ||
short). | ||
|
||
We also provide stand-alone packages that extend the Flame functionality: | ||
|
||
- [flame_audio](https://pub.dev/packages/flame_audio) Which provides audio capabilities using the | ||
`audioplayers` package. | ||
- [flame_forge2d](https://pub.dev/packages/flame_forge2d) Which provides physics capabilities using | ||
our own `Box2D` port called `Forge2D`. | ||
- [flame_tiled](https://pub.dev/packages/flame_tiled) Which provides integration with the | ||
[tiled](https://pub.dev/packages/tiled) package. | ||
- [flame_svg](https://pub.dev/packages/flame_svg) Which provides integration with | ||
[flutter_svg](https://pub.dev/packages/flutter_svg). | ||
|
||
You can pick and choose whichever parts you want, as they are all independent and modular. | ||
|
||
The engine and its ecosystem are constantly being improved by the community, so please feel free to | ||
reach out, open issues and PRs as well as make suggestions. | ||
|
||
Give us a star if you want to help give the engine exposure and grow the community. :) | ||
|
||
|
||
## Installation | ||
|
||
Put the pub package as your dependency by putting the following in your `pubspec.yaml`: | ||
|
||
```yaml | ||
dependencies: | ||
flame: 1.9.1 | ||
``` | ||
|
||
The latest version can be found on [pub.dev](https://pub.dev/packages/flame/install). | ||
|
||
then run `flutter pub get` and you are ready to start using it! | ||
|
||
|
||
## Getting started | ||
|
||
There is a set of tutorials that you can follow to get started in the | ||
[tutorials folder](https://github.com/flame-engine/flame/tree/main/doc/tutorials). | ||
|
||
Simple examples for all features can be found in the | ||
[examples folder](https://github.com/flame-engine/flame/tree/main/examples). | ||
|
||
You can also check out the [awesome flame | ||
repository](https://github.com/flame-engine/awesome-flame#user-content-articles--tutorials), | ||
it contains quite a lot of good tutorials and articles written by the community | ||
to get you started with Flame. | ||
|
||
|
||
## Outside of the scope of the engine | ||
|
||
Games sometimes require complex feature sets depending on what the game is all about. Some of these | ||
feature sets are outside of the scope of the Flame Engine ecosystem, in this section you can find | ||
them, and also some recommendations of packages/services that can be used: | ||
|
||
|
||
### Multiplayer (netcode) | ||
|
||
Flame doesn't bundle any network feature, which may be needed to write online multiplayer games. | ||
|
||
If you are building a multiplayer game, here are some recommendations of packages/services: | ||
|
||
- [Nakama](https://github.com/obrunsmann/flutter_nakama/): Nakama is an open-source server designed | ||
to power modern games and apps. | ||
- [Firebase](https://firebase.google.com/): Provides dozens of services that can be used to write | ||
simpler multiplayer experiences. | ||
- [Supabase](https://supabase.com/): A cheaper alternative to Firebase, based on Postgres. | ||
|
||
|
||
### External assets | ||
|
||
Flame doesn't bundle any helpers to load assets from an external source (external storage or online | ||
sources). | ||
|
||
But most of Flame's API can be loaded from concrete asset instances, for examples, `Sprite`s can be | ||
created from `dart:ui`s `Image` instances, so the user can write custom code to load images from | ||
anywhere they need, and then load it into Flame's classes. | ||
|
||
Here are some suggestions for http client packages: | ||
|
||
- [http](https://pub.dev/packages/http): A simple package for performing http requests. | ||
- [Dio](https://pub.dev/packages/dio): A popular and powerful package for performing http requests. |
95 changes: 95 additions & 0 deletions
95
docs/1.9.1/_sources/bridge_packages/bridge_packages.md.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Bridge Packages | ||
|
||
:::{package} flame_audio | ||
|
||
Play multiple audio files simultaneously (bridge package for [AudioPlayers]). | ||
::: | ||
|
||
:::{package} flame_bloc | ||
|
||
A predictable state management library (bridge package for [Bloc]). | ||
::: | ||
|
||
:::{package} flame_fire_atlas | ||
|
||
Create texture atlases for games (bridge package for [FireAtlas]). | ||
::: | ||
|
||
:::{package} flame_forge2d | ||
|
||
A Box2D physics engine (bridge package for [Forge2D]). | ||
::: | ||
|
||
:::{package} flame_isolate | ||
|
||
Use isolates to offload heavy computations to another thread. | ||
::: | ||
|
||
:::{package} flame_lottie | ||
|
||
Use Lottie animations in Flame (bridge package for [Lottie]). | ||
::: | ||
|
||
:::{package} flame_network_assets | ||
|
||
Fetch assets over the network. | ||
::: | ||
|
||
:::{package} flame_oxygen | ||
|
||
Replace FCS with the Oxygen Entity Component System. | ||
::: | ||
|
||
:::{package} flame_rive | ||
|
||
Create interactive animations (bridge package for [Rive]). | ||
::: | ||
|
||
:::{package} flame_spine | ||
|
||
Use Spine skeletal animations (bridge package for [Spine]). | ||
::: | ||
|
||
:::{package} flame_splash_screen | ||
|
||
Add the "Powered by Flame" splash screen. | ||
::: | ||
|
||
:::{package} flame_svg | ||
|
||
Draw SVG files in Flutter (bridge package for [flutter_svg]). | ||
::: | ||
|
||
:::{package} flame_tiled | ||
|
||
2D tilemap level editor (bridge package for [Tiled]). | ||
::: | ||
|
||
[AudioPlayers]: https://github.com/bluefireteam/audioplayers | ||
[Bloc]: https://github.com/felangel/bloc | ||
[FireAtlas]: https://github.com/flame-engine/fire-atlas | ||
[Forge2D]: https://github.com/flame-engine/forge2d | ||
[Lottie]: https://pub.dev/packages/lottie | ||
[Rive]: https://rive.app/ | ||
[Spine]: https://pub.dev/packages/spine_flutter | ||
[Tiled]: https://www.mapeditor.org/ | ||
[flutter_svg]: https://github.com/dnfield/flutter_svg | ||
|
||
|
||
```{toctree} | ||
:hidden: | ||
|
||
flame_audio <flame_audio/flame_audio.md> | ||
flame_bloc <flame_bloc/flame_bloc.md> | ||
flame_fire_atlas <flame_fire_atlas/flame_fire_atlas.md> | ||
flame_forge2d <flame_forge2d/flame_forge2d.md> | ||
flame_isolate <flame_isolate/flame_isolate.md> | ||
flame_lottie <flame_lottie/flame_lottie.md> | ||
flame_network_assets <flame_network_assets/flame_network_assets.md> | ||
flame_oxygen <flame_oxygen/flame_oxygen.md> | ||
flame_rive <flame_rive/flame_rive.md> | ||
flame_splash_screen <flame_splash_screen/flame_splash_screen.md> | ||
flame_spine <flame_spine/flame_spine.md> | ||
flame_svg <flame_svg/flame_svg.md> | ||
flame_tiled <flame_tiled/flame_tiled.md> | ||
``` |
111 changes: 111 additions & 0 deletions
111
docs/1.9.1/_sources/bridge_packages/flame_audio/audio.md.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Audio | ||
|
||
Playing audio is essential for most games, so we made it simple! | ||
|
||
First you have to add [flame_audio](https://github.com/flame-engine/flame_audio) to your dependency | ||
list in your `pubspec.yaml` file: | ||
|
||
```yaml | ||
dependencies: | ||
flame_audio: VERSION | ||
``` | ||
|
||
The latest version can be found on [pub.dev](https://pub.dev/packages/flame_audio/install). | ||
|
||
After installing the `flame_audio` package, you can add audio files in the assets section of your | ||
`pubspec.yaml` file. Make sure that the audio files exists in the paths that you provide. | ||
|
||
The default directory for `FlameAudio` is `assets/audio` (which can be changed by providing your own | ||
instance of `AudioCache`). | ||
|
||
For the examples below, your `pubspec.yaml` file needs to contain something like this: | ||
|
||
```yaml | ||
flutter: | ||
assets: | ||
- assets/audio/explosion.mp3 | ||
- assets/audio/music.mp3 | ||
``` | ||
|
||
Then you have the following methods at your disposal: | ||
|
||
```dart | ||
import 'package:flame_audio/flame_audio.dart'; | ||
|
||
// For shorter reused audio clips, like sound effects | ||
FlameAudio.play('explosion.mp3'); | ||
|
||
// For looping an audio file | ||
FlameAudio.loop('music.mp3'); | ||
|
||
// For playing a longer audio file | ||
FlameAudio.playLongAudio('music.mp3'); | ||
|
||
// For looping a longer audio file | ||
FlameAudio.loopLongAudio('music.mp3'); | ||
|
||
// For background music that should be paused/played when the pausing/resuming | ||
// the game | ||
FlameAudio.bgm.play('music.mp3'); | ||
``` | ||
|
||
The difference between the `play/loop` and `playLongAudio/loopLongAudio` is that `play/loop` makes | ||
use of optimized features that allow sounds to be looped without gaps between their iterations, and | ||
almost no drop on the game frame rate will happen. You should whenever possible, prefer the former | ||
methods. | ||
|
||
`playLongAudio/loopLongAudio` allows for audios of any length to be played, but they do create frame | ||
rate drop, and the looped audio will have a small gap between iterations. | ||
|
||
You can use [the `Bgm` class](bgm.md) (via `FlameAudio.bgm`) to play looping background music | ||
tracks. The `Bgm` class lets Flame automatically manage the pausing and resuming of background music | ||
tracks when the game is sent to background or comes back to the foreground. | ||
|
||
You can use [the `AudioPool` class](audio_pool.md) if you want to fire quick sound effects in a very | ||
efficient manner. `AudioPool` will keep a pool of `AudioPlayer`s preloaded with a given sound, and | ||
allow you to play them very fast in quick succession. | ||
|
||
Some file formats that work across devices and that we recommend are: MP3, OGG and WAV. | ||
|
||
This bridge library (flame_audio) uses [audioplayers](https://github.com/bluefireteam/audioplayers) | ||
in order to allow for playing multiple sounds simultaneously (crucial in a game). You can check the | ||
link for a more in-depth explanation. | ||
|
||
Both on `play` and `loop` you can pass an additional optional double parameter, the `volume` | ||
(defaults to `1.0`). | ||
|
||
Both the `play` and `loop` methods return an instance of an `AudioPlayer` from the | ||
[audioplayers](https://github.com/bluefireteam/audioplayers) lib, that allows you to stop, pause and | ||
configure other parameters. | ||
|
||
In fact you can always use `AudioPlayer`s directly to gain full control over how your audio is played | ||
-- the `FlameAudio` class is just a wrapper for common functionality. | ||
|
||
|
||
## Caching | ||
|
||
You can pre-load your assets. Audios need to be stored in the memory the first time they | ||
are requested; therefore, the first time you play each mp3 you might get a delay. In order to | ||
pre-load your audios, just use: | ||
|
||
```dart | ||
await FlameAudio.audioCache.load('explosion.mp3'); | ||
``` | ||
|
||
You can load all your audios in the beginning in your game's `onLoad` method so that they always | ||
play smoothly. To load multiple audio files, use the `loadAll` method: | ||
|
||
```dart | ||
await FlameAudio.audioCache.loadAll(['explosion.mp3', 'music.mp3']); | ||
``` | ||
|
||
Finally, you can use the `clear` method to remove a file that has been loaded into the cache: | ||
|
||
```dart | ||
FlameAudio.audioCache.clear('explosion.mp3'); | ||
``` | ||
|
||
There is also a `clearCache` method, that clears the whole cache. | ||
|
||
This might be useful if, for instance, your game has multiple levels and each has a different | ||
set of sounds and music. |
15 changes: 15 additions & 0 deletions
15
docs/1.9.1/_sources/bridge_packages/flame_audio/audio_pool.md.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# AudioPool | ||
|
||
An AudioPool is a provider of AudioPlayers that are pre-loaded with | ||
local assets to minimize delays. | ||
|
||
A single AudioPool always plays the same sound, usually a quick sound | ||
effect, like a laser shooting from your ship or a jump sound for your | ||
platformer. | ||
|
||
The advantage of using Audio Pool is that by configuring a minimum | ||
(starting) size, and a maximum size, the pool will create and preload | ||
some players, and allow them to be re-used many times. | ||
|
||
You can use the helper method `FlameAudio.createPool` to create AudioPool | ||
instances using the same global `FlameAudio.audioCache`. |
Oops, something went wrong.