Skip to content

Commit

Permalink
Add UI instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
theredfish committed Jun 7, 2024
1 parent aa080d7 commit 7c77fc5
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions examples/camera/2d_top_down_camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use bevy::core_pipeline::bloom::BloomSettings;
use bevy::log::{Level, LogPlugin};
use bevy::math::{vec2, vec3};
use bevy::prelude::*;
use bevy::sprite::{Material2d, MaterialMesh2dBundle, Mesh2dHandle};
use bevy::sprite::{MaterialMesh2dBundle, Mesh2dHandle};

/// Player movement speed factor.
const PLAYER_SPEED: f32 = 100.;
Expand All @@ -32,7 +32,10 @@ fn main() {
..default()
}))
.insert_resource(ClearColor(Color::BLACK))
.add_systems(Startup, (setup_scene, setup_camera).chain())
.add_systems(
Startup,
(setup_scene, setup_instructions, setup_camera).chain(),
)
.add_systems(Update, (move_player, update_camera).chain())
.run();
}
Expand Down Expand Up @@ -66,6 +69,21 @@ fn setup_scene(
debug!("Scene setup finished");
}

fn setup_instructions(mut commands: Commands) {
commands.spawn(
TextBundle::from_section(
"Move the light with ZQSD or WASD.\nThe camera will smoothly track the light.",
TextStyle::default(),
)
.with_style(Style {
position_type: PositionType::Absolute,
bottom: Val::Px(12.0),
left: Val::Px(12.0),
..default()
}),
);
}

fn setup_camera(mut commands: Commands) {
commands.spawn((
Camera2dBundle {
Expand Down

0 comments on commit 7c77fc5

Please sign in to comment.