start in full screen with mouse grabbed

This commit is contained in:
yuni 2024-03-16 19:07:28 +01:00
parent 43004caffc
commit a7321f73fb

View file

@ -1,5 +1,10 @@
use bevy::{
asset::LoadState,
window::{
Window,
WindowMode,
PrimaryWindow,
},
core_pipeline::Skybox,
prelude::*,
render::{
@ -35,8 +40,17 @@ const CUBEMAPS: &[(&str, CompressedImageFormats)] = &[
),
];
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
fn setup(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut windows: Query<&mut Window, With<PrimaryWindow>>
) {
let skybox_handle = asset_server.load(CUBEMAPS[0].0);
for mut window in &mut windows {
window.cursor.grab_mode = CursorGrabMode::Locked;
window.cursor.visible = false;
window.mode = WindowMode::Fullscreen;
}
// camera
commands.spawn((
Camera3dBundle {
@ -233,6 +247,7 @@ fn run_camera_controller(
controller.yaw = yaw;
controller.pitch = pitch;
controller.initialized = true;
*toggle_cursor_grab = true;
info!("{}", *controller);
}
if !controller.enabled {