Skip to content

How do I get the current window width and window size? #14568

Answered by Guelakais
Guelakais asked this question in Q&A
Discussion options

You must be logged in to vote

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:

fn setup_instructions(mut commands: Commands, windows: Query<&mut Window>) {
    commands.spawn(
        TextBundle::from_section("", TextStyle::default()).with_style(Style {
            position_type: PositionType::Absolute,
            top: Val::Px(12.0/windows.single().resolution.height()),
            left: Val::Px(12.0/windows.single().resolution.width()),
            ..default()
        }),
    );
}

Ai circles, which no longer disappear from the playing field:

fn calculate_translation(border: f32, current_number: f32, mut rng: ThreadRng) -> f32 {

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Guelakais
Comment options

Answer selected by Guelakais
@rparrett
Comment options

@Guelakais
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants