-
Unless otherwise specified, bevy sets the window size itself. I wanted to access exactly these values in my setup and update methods, as in the following example: fn setup_instructions(mut commands: Commands,windows: WindowResolution) {
commands.spawn(
TextBundle::from_section("", TextStyle::default()).with_style(Style {
position_type: PositionType::Absolute,
top: Val::Px(12.0*windows.height()),
left: Val::Px(12.0*windows.width()),
..default()
}),
);
} How do you get it right? |
Beta Was this translation helpful? Give feedback.
Answered by
Guelakais
Aug 1, 2024
Replies: 1 comment 3 replies
-
fn toggle_resolution(
mut windows: Query<&mut Window>,
) {
let mut window = windows.single_mut(); // Get window
println!(window.resolution.width(), window.resolution.height());
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Almost. I have now found out how to integrate it correctly:
The setup method in which the text now behaves in relation to the window width:
Ai circles, which no longer disappear from the playing field: