1

Problems with Bevy version 0.10.0 WindowDescriptor struct

I saw this tutorial:Bevy Game Engine Tutorial - Window and First Sprite (Ep1 and I tried to do the same thing, but my Bevy is in version 0.10.0, and this structure WindowDescriptor is not working, I've tried to do it in other ways seen here on Stack OverFlow but without success with that so far!

My code is like this:

use bevy::prelude::*;

pub const CLEAR: Color = Color::rgb(0.1, 0.1, 0.1);

fn main() {
    App::new()
    .insert_resource(ClearColor(CLEAR))
    .insert_resource(WindowDescriptor {
            title: "Bevy Demo".to_string(),
            width: 1600.0,
            height: 900.0,
            vsync: true,
            resizable: true,
            ..Default::default()
    })
    .add_plugins(DefaultPlugins)
    .run();
}

My Cargo.toml looks like this:

[package]
name = "test-bevy-game"
version = "0.1.0"
edition = "2021"

[profile.dev]
opt-level = 1

[profile.dev.package."*"]
opt-level = 3

[dependencies]
bevy = { version = "0.10.1", features = ["dynamic_linking"] }

And the debug error is this:

error[E0422]: cannot find struct, variant or union type `WindowDescriptor` in this scope
 --> src\main.rs:8:22
  |
8 |     .insert_resource(WindowDescriptor {
  |                      ^^^^^^^^^^^^^^^^ not found in this scope

For more information about this error, try `rustc --explain E0422`.
error: could not compile `test-bevy-game` due to previous error

I just don't want the compiler to give me any errors about this, I hope I can at least add the ecs vsync, width, height, title statically in my code, I want to know if bevy in version 0.10.0 need to change the version to an older one?

GabOnezio
  • 11
  • 2

1 Answers1

2

The best way to see how things are done in various versions of Bevy (since development is still pretty rapid) is to look through their extensive set of examples. The one for window settings can give us the basics:

App::new()
    .add_plugins(DefaultPlugins.set(WindowPlugin {
        primary_window: Some(Window {
            title: "I am a window!".into(),
            resolution: (500., 300.).into(),
            present_mode: PresentMode::AutoVsync,
            ..default()
        }),
        ..default()
    }))

So you can specify the details for the window by creating a Window and provide it as the primary_window of the WindowPlugin when setting up your app. You would then access the Window later through a Query if you need to.

kmdreko
  • 42,554
  • 6
  • 57
  • 106