mirror of
https://github.com/seemueller-io/yachtpit.git
synced 2025-09-08 22:46:45 +00:00
init
This commit is contained in:
41
mobile/src/lib.rs
Normal file
41
mobile/src/lib.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy::window::WindowMode;
|
||||
use bevy::winit::WinitSettings;
|
||||
use yachtpit::GamePlugin;
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn main_rs() {
|
||||
main();
|
||||
}
|
||||
|
||||
// this macro is a no-op on ios and only needed for anroid since bevy 0.16
|
||||
// see https://github.com/bevyengine/bevy/pull/14780
|
||||
#[bevy_main]
|
||||
fn main() {
|
||||
#[cfg(target_os = "ios")]
|
||||
unsafe {
|
||||
// Sets our audio session to Ambient mode to prevent background music from stopping.
|
||||
// The default for iOS apps is SoloAmbient, which stops background music.
|
||||
// See apple docs: https://developer.apple.com/documentation/avfaudio/avaudiosession/category-swift.struct/ambient
|
||||
if let Err(e) = objc2_avf_audio::AVAudioSession::sharedInstance()
|
||||
.setCategory_error(objc2_avf_audio::AVAudioSessionCategoryAmbient.unwrap())
|
||||
{
|
||||
println!("Error setting audio session category: {:?}", e);
|
||||
}
|
||||
}
|
||||
|
||||
App::new()
|
||||
.insert_resource(WinitSettings::mobile())
|
||||
.add_plugins((
|
||||
DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
resizable: false,
|
||||
mode: WindowMode::BorderlessFullscreen(MonitorSelection::Current),
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
}),
|
||||
GamePlugin,
|
||||
))
|
||||
.run();
|
||||
}
|
Reference in New Issue
Block a user