WIP: Adding the menu #110

Draft
raphael wants to merge 13 commits from new-menu into main
2 changed files with 6 additions and 6 deletions
Showing only changes of commit ed49d489b4 - Show all commits

View file

@ -107,7 +107,7 @@ fn keyboard_movement_system(
/// Moves the camera with mouse input. /// Moves the camera with mouse input.
fn mouse_movement_system( fn mouse_movement_system(
mouse_button_input: Res<Input<MouseButton>>, mouse_button_input: Res<Input<MouseButton>>,
mut query: Query<&mut Transform, With<Camera>>, mut query: Query<(&mut Transform, &OrthographicProjection), With<Camera>>,
windows: Query<&Window>, windows: Query<&Window>,
mut last_position: Local<Option<Vec2>>, mut last_position: Local<Option<Vec2>>,
) { ) {
@ -125,9 +125,9 @@ fn mouse_movement_system(
} }
if let Some(old_position) = *last_position { if let Some(old_position) = *last_position {
for mut transform in query.iter_mut() { for (mut transform, projection) in query.iter_mut() {
let offset = (old_position - position).extend(0.0) * Vec3::new(1., -1., 1.); let offset = (old_position - position).extend(0.0) * Vec3::new(1., -1., 1.);
transform.translation += offset; transform.translation += offset * projection.scale;
} }
*last_position = Some(position); *last_position = Some(position);
} }

View file

@ -13,12 +13,12 @@ impl Plugin for HoverPlugin {
/// A component that stores the hover texture and the original texture. /// A component that stores the hover texture and the original texture.
#[derive(Component, Clone)] #[derive(Component, Clone)]
struct HoveredTexture { pub struct HoveredTexture {
/// The original texture. /// The original texture.
texture: Handle<Image>, pub texture: Handle<Image>,
/// The hovered texture. /// The hovered texture.
hovered_texture: Handle<Image>, pub hovered_texture: Handle<Image>,
} }
/// The system that applies the hover logic by changing the texture. /// The system that applies the hover logic by changing the texture.