forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clear_color.rs
24 lines (20 loc) · 722 Bytes
/
clear_color.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! Shows how to set the solid color that is used to paint the window before the frame gets drawn.
//!
//! Acts as background color, since pixels that are not drawn in a frame remain unchanged.
use bevy::prelude::*;
fn main() {
App::new()
.insert_resource(ClearColor(Color::rgb(0.5, 0.5, 0.9)))
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, change_clear_color)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
}
fn change_clear_color(input: Res<ButtonInput<KeyCode>>, mut clear_color: ResMut<ClearColor>) {
if input.just_pressed(KeyCode::Space) {
clear_color.0 = Color::PURPLE;
}
}