Crates.io | bevy_ios_gamecenter |
lib.rs | bevy_ios_gamecenter |
version | |
source | src |
created_at | 2024-05-05 12:30:45.259057+00 |
updated_at | 2025-04-26 19:51:52.965747+00 |
description | Bevy Plugin and Swift Package to provide access to iOS native GameKit (Gamecenter) from inside Bevy Apps |
homepage | |
repository | https://github.com/rustunit/bevy_ios_gamecenter |
max_upload_size | |
id | 1230199 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Bevy Plugin and Swift Package to provide access to iOS native GameKit (Gamecenter) from inside Bevy Apps It uses Swift-Bridge to auto-generate the glue code and transport data types.
Demo from our game using this crate: zoolitaire.com
Add GameKit
framework:
Go to File
-> Add Package Dependencies
and paste https://github.com/rustunit/bevy_ios_gamecenter.git
into the search bar on the top right:
Note:
The rust crate used must be exactly the same version as the Swift Package.
I suggest using a specific version (like 0.2.0
in the screenshot) to make sure to always use binary matching versions!
cargo add bevy_ios_gamecenter
or
# always pin to the same exact version you also of the Swift package
bevy_ios_gamecenter = { version = "=0.4.0" }
Initialize Bevy Plugin:
// init right on startup
app.add_plugins(IosGamecenterPlugin::new(true));
fn bevy_system(mut gc: BevyIosGamecenter) {
gc.authenticate()
.on_response(|trigger: Trigger<IosGCAuthResult>| match &trigger.event().0 {
IosGCAuthResult::IsAuthenticated => {},
IosGCAuthResult::LoginPresented => {},
IosGCAuthResult::Error(e) => error!("auth error: {e}"),
});
// here we request the player info type for the username and more
// Note: all requests via `gc` of type `BevyIosGamecenter`
// allow to attach an observer to listen to the response:
gc.request_player().on_response(on_player_response);
// update achievement progress, 100 % will complete it
gc.achievement_progress("id".into(),100.);
// reset all achievements
gc.achievements_reset();
// save a game state as a byte slice
gc.save_game("test".into(), vec![1, 2, 3].as_slice());
// request list of `IosGCSaveGame`
gc.fetch_save_games().on_response(on_response);
// based on result of above `fetch_save_games` request
let save_game = IosGCSaveGame {..}
gc.load_game(save_game);
// update leaderboard score
gc.leaderboards_score(
"raking id".into(),
// score
1,
// context
2,
);
// open gamecenter view (leaderboard)
gc.trigger_view(view_states::LEADERBOARDS);
}
bevy | bevy_ios_gamecenter |
---|---|
0.16 | 0.4,main |
0.15 | 0.3 |
0.14 | 0.2 |
0.13 | 0.1 |
All code in this repository is dual-licensed under either:
at your option. This means you can select the license you prefer.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.