Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Player extends SpriteComponent {
@override
Future<void> onLoad() async {
sprite = await Sprite.load('player.png');
sprite = await Sprite.load('assets/images/player.png');
}
}
```
Expand Down Expand Up @@ -151,7 +151,7 @@ class Player extends SpriteComponent with TapCallbacks {
@override
Future<void> onLoad() async {
sprite = await Sprite.load('player.png');
sprite = await Sprite.load('assets/images/player.png');
}
@override
Expand Down
17 changes: 10 additions & 7 deletions doc/bridge_packages/flame_audio/audio.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ Then you have the following methods at your disposal:
import 'package:flame_audio/flame_audio.dart';

// For shorter reused audio clips, like sound effects
FlameAudio.play('explosion.mp3');
FlameAudio.play('assets/audio/explosion.mp3');

// For looping an audio file
FlameAudio.loop('music.mp3');
FlameAudio.loop('assets/audio/music.mp3');

// For playing a longer audio file
FlameAudio.playLongAudio('music.mp3');
FlameAudio.playLongAudio('assets/audio/music.mp3');

// For looping a longer audio file
FlameAudio.loopLongAudio('music.mp3');
FlameAudio.loopLongAudio('assets/audio/music.mp3');

// For background music that should be paused/played when the pausing/resuming
// the game
FlameAudio.bgm.play('music.mp3');
FlameAudio.bgm.play('assets/audio/music.mp3');
```

The difference between the `play/loop` and `playLongAudio/loopLongAudio` is that `play/loop` makes
Expand Down Expand Up @@ -89,14 +89,17 @@ are requested; therefore, the first time you play each mp3 you might get a delay
pre-load your audios, just use:

```dart
await FlameAudio.audioCache.load('explosion.mp3');
await FlameAudio.audioCache.load('assets/audio/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']);
await FlameAudio.audioCache.loadAll([
'assets/audio/explosion.mp3',
'assets/audio/music.mp3',
]);
```

Finally, you can use the `clear` method to remove a file that has been loaded into the cache:
Expand Down
6 changes: 3 additions & 3 deletions doc/bridge_packages/flame_audio/audio_pool.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Future<void> loadSounds() async {
// Create a pool with minimum 1 player and maximum 2 players
// This automatically uses Flame's global audio cache
AudioPool explosionSoundPool = await FlameAudio.createPool(
'explosion.mp3',
'assets/audio/explosion.mp3',
minPlayers: 1,
maxPlayers: 2,
);
Expand Down Expand Up @@ -144,13 +144,13 @@ class MyGame extends FlameGame {
Future<void> onLoad() async {
// Load sound effects into audio pools
laserSound = await FlameAudio.createPool(
'laser.mp3',
'assets/audio/laser.mp3',
minPlayers: 3,
maxPlayers: 6,
);

explosionSound = await FlameAudio.createPool(
'explosion.mp3',
'assets/audio/explosion.mp3',
minPlayers: 2,
maxPlayers: 4,
);
Expand Down
6 changes: 3 additions & 3 deletions doc/bridge_packages/flame_audio/bgm.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ To play a looping background music track, run:
```dart
import 'package:flame_audio/flame_audio.dart';

FlameAudio.bgm.play('adventure-track.mp3');
FlameAudio.bgm.play('assets/audio/adventure-track.mp3');
```

You must have an appropriate folder structure and add the files to the `pubspec.yaml` file, as
Expand Down Expand Up @@ -61,11 +61,11 @@ You can pass an additional optional `double` parameter which is the `volume` (de
Examples:

```dart
FlameAudio.bgm.play('music/boss-fight/level-382.mp3');
FlameAudio.bgm.play('assets/audio/music/boss-fight/level-382.mp3');
```

```dart
FlameAudio.bgm.play('music/world-map.mp3', volume: .25);
FlameAudio.bgm.play('assets/audio/music/world-map.mp3', volume: .25);
```


Expand Down
6 changes: 3 additions & 3 deletions doc/bridge_packages/flame_fire_atlas/fire_atlas.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ import 'package:flame_fire_atlas/flame_fire_atlas.dart';

// Load the atlas from your assets
// file at assets/atlas.fa
final atlas = await FireAtlas.loadAsset('atlas.fa');
final atlas = await FireAtlas.loadAsset('assets/atlas.fa');

//or when inside a game instance, the loadFireAtlas can be used:
// file at assets/atlas.fa
final atlas = await loadFireAtlas('atlas.fa');
final atlas = await loadFireAtlas('assets/atlas.fa');

// Get a Sprite with the given key.
FireAtlas.getSprite('sprite_name')
Expand All @@ -75,7 +75,7 @@ class ExampleGame extends FlameGame {

@override
Future<void> onLoad() async {
_atlas = await loadFireAtlas('atlas.fa');
_atlas = await loadFireAtlas('assets/atlas.fa');

add(
SpriteComponent(
Expand Down
4 changes: 2 additions & 2 deletions doc/bridge_packages/flame_svg/svg.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To use it just import the `Svg` class from `'package:flame_svg/flame_svg.dart'`,
following snippet to render it on the canvas:

```dart
final svgInstance = await Svg.load('android.svg');
final svgInstance = await Svg.load('assets/android.svg');

final position = Vector2(100, 100);
final size = Vector2(300, 300);
Expand All @@ -32,7 +32,7 @@ or use the `SvgComponent` and add it to the component tree:
class MyGame extends FlameGame {
@override
Future<void> onLoad() async {
final svgInstance = await Svg.load('android.svg');
final svgInstance = await Svg.load('assets/android.svg');
final size = Vector2.all(100);
final position = Vector2.all(100);
final svgComponent = SvgComponent(
Expand Down
16 changes: 7 additions & 9 deletions doc/bridge_packages/flame_texturepacker/flame_texturepacker.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MyGame extends FlameGame {
@override
Future<void> onLoad() async {
// Load the texture atlas
final atlas = await atlasFromAssets('atlas_map.atlas');
final atlas = await atlasFromAssets('assets/images/atlas_map.atlas');

// Use the atlas to get sprites
final sprite = atlas.findSpriteByName('robot_jump')!;
Expand Down Expand Up @@ -109,7 +109,7 @@ names contain any of the whitelist strings will be loaded:

```dart
final atlas = await TexturePackerAtlas.load(
'atlas_map.atlas',
'assets/images/atlas_map.atlas',
whiteList: [ 'robot_walk' ]
);
```
Expand All @@ -124,21 +124,19 @@ TexturePacker can trim transparent pixels from sprites to save space. By default

```dart
final atlas = await TexturePackerAtlas.load(
'atlas_map.atlas',
'assets/images/atlas_map.atlas',
useOriginalSize: false, // Use the trimmed/packed size instead
);
```


### Custom Asset Prefix
### Atlas Location

If your ``.atlas`` data file is not stored in the default `images` directory:
The ``.atlas`` path is a full asset path, so the file can live anywhere. Page textures listed
inside the atlas are resolved relative to the atlas's own directory:

```dart
final atlas = await atlasFromAssets(
'atlas_map.atlas',
assetsPrefix: 'custom_path',
);
final atlas = await atlasFromAssets('assets/atlases/atlas_map.atlas');
```


Expand Down
6 changes: 3 additions & 3 deletions doc/bridge_packages/flame_tiled/flame_tiled.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To use this,

```dart
final component = await TiledComponent.load(
'my_map.tmx',
'assets/tiles/my_map.tmx',
Vector2.all(32),
);

Expand Down Expand Up @@ -80,7 +80,7 @@ resizing the original tileset images so that when packed they fit with the limit

```dart
final component = await TiledComponent.load(
'my_map.tmx',
'assets/tiles/my_map.tmx',
Vector2.all(32),
atlasMaxX: 9216,
atlasMaxY: 9216,
Expand All @@ -106,7 +106,7 @@ where the sum of their dimensions are in the thousands.

```dart
final component = await TiledComponent.load(
'my_map.tmx',
'assets/tiles/my_map.tmx',
Vector2.all(32),
ignoreFlip: true,
);
Expand Down
14 changes: 7 additions & 7 deletions doc/flame/components/parallax_component.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ The simplest `ParallaxComponent` is created like this:
@override
Future<void> onLoad() async {
final parallaxComponent = await loadParallaxComponent([
ParallaxImageData('bg.png'),
ParallaxImageData('trees.png'),
ParallaxImageData('assets/images/bg.png'),
ParallaxImageData('assets/images/trees.png'),
]);
add(parallaxComponent);
}
Expand All @@ -30,8 +30,8 @@ class MyParallaxComponent extends ParallaxComponent<MyGame> {
@override
Future<void> onLoad() async {
parallax = await game.loadParallax([
ParallaxImageData('bg.png'),
ParallaxImageData('trees.png'),
ParallaxImageData('assets/images/bg.png'),
ParallaxImageData('assets/images/trees.png'),
]);
}
}
Expand Down Expand Up @@ -86,19 +86,19 @@ Advanced example:
```dart
final images = [
loadParallaxImage(
'stars.jpg',
'assets/images/stars.jpg',
repeat: ImageRepeat.repeat,
alignment: Alignment.center,
fill: LayerFill.width,
),
loadParallaxImage(
'planets.jpg',
'assets/images/planets.jpg',
repeat: ImageRepeat.repeatY,
alignment: Alignment.bottomLeft,
fill: LayerFill.none,
),
loadParallaxImage(
'dust.jpg',
'assets/images/dust.jpg',
repeat: ImageRepeat.repeatX,
alignment: Alignment.topRight,
fill: LayerFill.height,
Expand Down
4 changes: 2 additions & 2 deletions doc/flame/components/sprite_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MyGame extends FlameGame {

@override
Future<void> onLoad() async {
final sprite = await Sprite.load('player.png');
final sprite = await Sprite.load('assets/images/player.png');
final size = Vector2.all(128.0);
final player = SpriteComponent(size: size, sprite: sprite);

Expand Down Expand Up @@ -72,7 +72,7 @@ Future<void> onLoad() async {
stepTime: 0.1,
);
this.player = SpriteAnimationComponent.fromFrameData(
await images.load('player.png'),
await images.load('assets/images/player.png'),
data,
);
}
Expand Down
4 changes: 2 additions & 2 deletions doc/flame/components/utility_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ rendered in the game:
```dart
@override
Future<void> onLoad() async {
final svg = await Svg.load('android.svg');
final svg = await Svg.load('assets/android.svg');
final android = SvgComponent.fromSvg(
svg,
position: Vector2.all(100),
Expand All @@ -108,7 +108,7 @@ A simple example on how to use it:
```dart
// Creates a tileset, the block ids are automatically assigned sequentially
// starting at 0, from left to right and then top to bottom.
final tilesetImage = await images.load('tileset.png');
final tilesetImage = await images.load('assets/images/tileset.png');
final tileset = SpriteSheet(image: tilesetImage, srcSize: Vector2.all(32));
// Each element is a block id, -1 means nothing
final matrix = [[0, 1, 0], [1, 0, 0], [1, 1, 1]];
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/examples/lib/ember.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EmberPlayer extends SpriteAnimationComponent with TapCallbacks {
@override
Future<void> onLoad() async {
animation = SpriteAnimation.fromFrameData(
await Flame.images.load('ember.png'),
await Flame.images.load('assets/images/ember.png'),
SpriteAnimationData.sequenced(
amount: 4,
textureSize: Vector2.all(16),
Expand Down
2 changes: 1 addition & 1 deletion doc/flame/game.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MyCrate extends SpriteComponent {
@override
Future<void> onLoad() async {
sprite = await Sprite.load('crate.png');
sprite = await Sprite.load('assets/images/crate.png');
}
}
Expand Down
4 changes: 2 additions & 2 deletions doc/flame/inputs/other_inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MyGame extends FlameGame {
@override
Future<void> onLoad() async {
super.onLoad();
final image = await images.load('joystick.png');
final image = await images.load('assets/images/joystick.png');
final sheet = SpriteSheet.fromColumnsAndRows(
image: image,
columns: 6,
Expand Down Expand Up @@ -60,7 +60,7 @@ class Player extends SpriteComponent with HasGameReference {
@override
Future<void> onLoad() async {
sprite = await game.loadSprite('layers/player.png');
sprite = await game.loadSprite('assets/images/layers/player.png');
position = game.size / 2;
}
Expand Down
Loading
Loading