diff --git a/crates/border-wars/src/camera.rs b/crates/border-wars/src/camera.rs index c19a3e2..b22dd92 100644 --- a/crates/border-wars/src/camera.rs +++ b/crates/border-wars/src/camera.rs @@ -107,7 +107,7 @@ fn keyboard_movement_system( /// Moves the camera with mouse input. fn mouse_movement_system( mouse_button_input: Res>, - mut query: Query<&mut Transform, With>, + mut query: Query<(&mut Transform, &OrthographicProjection), With>, windows: Query<&Window>, mut last_position: Local>, ) { @@ -125,9 +125,9 @@ fn mouse_movement_system( } 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.); - transform.translation += offset; + transform.translation += offset * projection.scale; } *last_position = Some(position); } diff --git a/crates/border-wars/src/ui/hover.rs b/crates/border-wars/src/ui/hover.rs index 632dc07..2d82f18 100644 --- a/crates/border-wars/src/ui/hover.rs +++ b/crates/border-wars/src/ui/hover.rs @@ -13,12 +13,12 @@ impl Plugin for HoverPlugin { /// A component that stores the hover texture and the original texture. #[derive(Component, Clone)] -struct HoveredTexture { +pub struct HoveredTexture { /// The original texture. - texture: Handle, + pub texture: Handle, /// The hovered texture. - hovered_texture: Handle, + pub hovered_texture: Handle, } /// The system that applies the hover logic by changing the texture.