Skip to content

Commit

Permalink
Merge pull request #92 from NiklasEi/update_bevy_asset_loader_and_doc…
Browse files Browse the repository at this point in the history
…ument_mobile_setup

Update bevy asset loader and document mobile setup
  • Loading branch information
NiklasEi authored Dec 27, 2023
2 parents c084470 + b116083 commit 6b1517f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bevy = { version = "0.12", default-features = false, features = [
"webgl2",
] }
bevy_kira_audio = { version = "0.18" }
bevy_asset_loader = { version = "0.18" }
bevy_asset_loader = { version = "0.19" }
rand = { version = "0.8.3" }
webbrowser = { version = "0.8", features = ["hardened"] }

Expand Down
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# A Bevy game template

Template for a Game using the awesome [Bevy engine][bevy] featuring out of the box builds for Windows, Linux, macOS, and Web (Wasm). It also includes the setup for android support.
Template for a Game using the awesome [Bevy engine][bevy] featuring out of the box builds for Windows, Linux, macOS, Web (Wasm), Android, and iOS.

_Since Bevy is in heavy development, there regularly are unpublished new features or bug fixes. If you like living on the edge, you can use the branch `bevy_main` of this template to be close to the current state of Bevy's main branch_

# What does this template give you?
* small example ["game"](https://niklasei.github.io/bevy_game_template/) (*warning: biased; e.g., split into a lot of plugins and using `bevy_kira_audio` for sound*)
* small example ["game"](https://niklasei.github.io/bevy_game_template/)
* easy setup for running the web build using [trunk] (`trunk serve`)
* run the native version with `cargo run`
* workflow for GitHub actions creating releases for Windows, Linux, macOS, and Web (Wasm) ready for distribution
* the same workflow creates development builds for the mobile platforms (two separate workflows can push to the stores after [some setup](#deploy-mobile-platforms))
* push a tag in the form of `v[0-9]+.[0-9]+.[0-9]+*` (e.g. `v1.1.42`) to trigger the flow
* WARNING: if you work in a private repository, please be aware that macOS and Windows runners cost more build minutes. You might want to consider running the workflow less often or removing some builds from it. **For public repositories the builds are free!**
* WARNING: if you work in a private repository, please be aware that macOS and Windows runners cost more build minutes. **For public repositories the builds are free!**

# How to use this template?
1. Click "Use this template" on the repository's page
Expand All @@ -22,7 +21,7 @@ _Since Bevy is in heavy development, there regularly are unpublished new feature
* requires [trunk]: `cargo install --locked trunk`
* requires `wasm32-unknown-unknown` target: `rustup target add wasm32-unknown-unknown`
* this will serve your app on `8080` and automatically rebuild + reload it after code changes
* Start the android app: `cargo apk run -p mobile` (update the library name if you changed it)
* Start the android app: `cargo apk run -p mobile`
* requires following the instructions in the [bevy example readme for android setup][android-instructions]
* Start the iOS app (see the [bevy example readme for ios setup instructions][ios-instructions])
* Install Xcode through the app store
Expand Down Expand Up @@ -52,6 +51,22 @@ To deploy newer versions, just run the `deploy-github-page` workflow again.

Note that this does a `cargo build` and thus does not work with local dependencies. Consider pushing your "custom Bevy fork" to GitHub and using it as a git dependency.

# Deploy mobile platforms

For general info on mobile support, you can take a look at [one of my blog posts about mobile development with Bevy][mobile_dev_with_bevy_2] which is relevant to the current setup.

## Android

Currently, `cargo-apk` is used to run the development app. But APKs can no longer be published in the store and `cargo-apk` cannot produce the required AAB. This is why there is setup for two android related tools. In [`mobile/Cargo.toml`](./mobile/Cargo.toml), the `package.metadata.android` section configures `cargo-apk` while [`mobile/manifest.yaml`](./mobile/manifest.yaml) configures a custom fork of `xbuild` which is used in the `release-android-google-play` workflow to create an AAB.

There is a [post about how to set up the android release workflow][workflow_bevy_android] on my blog.

## iOS

The setup is pretty much what Bevy does for the mobile example.

There is a [post about how to set up the iOS release workflow][workflow_bevy_ios] on my blog.

# Removing mobile platforms

If you don't want to target Android or iOS, you can just delete the `/mobile`, `/build/android`, and `/build/ios` directories.
Expand All @@ -76,7 +91,9 @@ This project is licensed under [CC0 1.0 Universal](LICENSE) except some content
[nikl-mastodon]: https://mastodon.online/@nikl_me
[firefox-sound-issue]: https://github.com/NiklasEi/bevy_kira_audio/issues/9
[Bevy Cheat Book]: https://bevy-cheatbook.github.io/introduction.html
[`wasm-server-runner`]: https://github.com/jakobhellermann/wasm-server-runner
[trunk]: https://trunkrs.dev/
[android-instructions]: https://github.com/bevyengine/bevy/blob/latest/examples/README.md#setup
[ios-instructions]: https://github.com/bevyengine/bevy/blob/latest/examples/README.md#setup-1
[mobile_dev_with_bevy_2]: https://www.nikl.me/blog/2023/notes_on_mobile_development_with_bevy_2/
[workflow_bevy_android]: https://www.nikl.me/blog/2023/github_workflow_to_publish_android_app/
[workflow_bevy_ios]: https://www.nikl.me/blog/2023/github_workflow_to_publish_ios_app/
2 changes: 1 addition & 1 deletion mobile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["staticlib", "cdylib"]
bevy_game = { path = ".." } # ToDo
bevy = { version = "0.12", default-features = false }

# As long as Kira doesn't expose a feature for this, we need to enable it our self
# As long as Kira doesn't expose a feature for this, we need to enable it
# See https://github.com/tesselode/kira/pull/51
[target."cfg(target_os = \"android\")".dependencies.cpal]
version = "0.15"
Expand Down
9 changes: 5 additions & 4 deletions src/loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ pub struct LoadingPlugin;
impl Plugin for LoadingPlugin {
fn build(&self, app: &mut App) {
app.add_loading_state(
LoadingState::new(GameState::Loading).continue_to_state(GameState::Menu),
)
.add_collection_to_loading_state::<_, AudioAssets>(GameState::Loading)
.add_collection_to_loading_state::<_, TextureAssets>(GameState::Loading);
LoadingState::new(GameState::Loading)
.continue_to_state(GameState::Menu)
.load_collection::<AudioAssets>()
.load_collection::<TextureAssets>(),
);
}
}

Expand Down

0 comments on commit 6b1517f

Please sign in to comment.