Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 1.95 KB

initializing_a_different_window.md

File metadata and controls

38 lines (29 loc) · 1.95 KB

Initializing A Different Window

The DefaultPlugins is a set of plugins. One of the plugins is the WindowPlugin, which defines an interface for windows. To initialize a window different from the default one, we can change the WindowPlugin by the set method of DefaultPlugins.

use bevy::app::PluginGroup;
use bevy::utils::default;
use bevy::window::{Window, WindowPlugin, WindowPosition};
use bevy::{app::App, DefaultPlugins};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins.set(WindowPlugin {
            primary_window: Some(Window {
                title: "A Bevy App".into(),
                position: WindowPosition::At((0, 0).into()),
                resolution: (200., 100.).into(),
                ..default()
            }),
            ..default()
        }))
        .run();
}

We set the primary_window field of the WindowPlugin by providing it with the Window struct and describing the appearance of our window.

The default function is a syntax sugar for Default::default in Bevy.

Result:

Initializing A Different Window

➡️ Next: Changing The Window After Initialization

📘 Back: Table of contents