You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.0 KiB
Rust

use games::*;
fn main() {
App::new()
.add_plugins(BaseGamePlugin {
target_resolution: (360.0, 640.0).into(),
..default()
})
.add_systems(Startup, init_window_info)
.add_systems(
Update,
update_window_info.run_if(any_component_changed::<Window>),
)
.run();
}
#[derive(Component)]
struct WindowInfo;
fn init_window_info(mut commands: Commands) {
commands.spawn((
Node {
align_self: AlignSelf::Center,
justify_self: JustifySelf::Center,
..default()
},
children![(Text::new("Placeholder"), WindowInfo,)],
));
}
fn update_window_info(mut text: Single<&mut Text, With<WindowInfo>>, window: Single<&Window>) {
text.0 = format!(
"Logical: {}x{}\nPhysical: {}x{}\nScale Factor: {}",
window.resolution.physical_width(),
window.resolution.physical_height(),
window.resolution.width(),
window.resolution.height(),
window.resolution.scale_factor(),
);
}