flame-engine / flame-engine/flame

feat: use the `AssetBundle` API to provide more familiar ways to load assets

Open
#3,252 2 comments 6 reactions 1 assignee Claimed by @wolfenrain View on GitHub
enhancement
Dominant language
Dart
Stars
10.8k
Forks
1k
Avg merge
1d 20h
Merged PRs (30d)
21

Description

### What could be improved

The way Flame handles assets is currently a bit ambiguous, images go through the `Images` class while other type of files (for instance tiled maps) have their own parsers in the bridge packages. This is also not the common way most Flutter developers are used to handling assets.

### Why should this be improved

Flutter already provides a way to load assets, that we internally already use, namely the `AssetBundle` class. This class however still does not provide direct ways to load asset types like images, tiled map and others. But we can extend it, and it even has a `CachedAssetBundle` variant that does caching for us.

My suggestion is to create a `FlameAssetBundle` that can load different kinds of types like images and tiled map (through extensions provided in the bridge package). This allows us to make it more user-friendly, flutter developers know about `rootBundle` and `AssetBundle` and allows our bridge packages to make loading assets for their implementation much easier.

### Risks

None to my knowledge, the `Images` can still exist for backwards compatibilty but under the hood it can use the Flame bundle system.

### More information

I already have been using this idea for my own games and would love to provide my implementation as a PR if we all agree on this idea.

### Other

- [X] Are you interested in working on a PR for this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.