Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
wolfenrain opened this issue Aug 5, 2024 · 2 comments
Open
1 task done
Assignees

Comments

@wolfenrain
Copy link
Contributor

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

  • Are you interested in working on a PR for this?
@wolfenrain wolfenrain changed the title feat: feat: use the AssetBundle API to provide more familiar ways to load assets Aug 5, 2024
@wolfenrain
Copy link
Contributor Author

For the implementation I am planning on doing 3 PRs:

  • Introduce the FlameAssetBinding class and make it available on the Flame namespace
  • Migrate the Images cache to use the Flame bundle API
  • Deprecate the Images API in favor of the Flame bundle

@spydon
Copy link
Member

spydon commented Oct 3, 2024

@wolfenrain you haven't forgotten this one right? 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants