generated from tipragot/rust
Add a camera system #69
|
@ -56,7 +56,13 @@ fn init_camera(mut commands: Commands) {
|
|||
commands.spawn(Camera2dBundle::default());
|
||||
}
|
||||
|
||||
/// Initializes the key movement settings for the camera.
|
||||
/// Initializes the resources related to the camera.
|
||||
CoCo_Sol marked this conversation as resolved
Outdated
|
||||
///
|
||||
/// - [KeysMovementSettings]: The key settings for camera movement.
|
||||
/// - [CameraSpeedMouvement]: The speed of camera movement.
|
||||
/// - [CameraSpeedScale]: The speed of camera scaling.
|
||||
/// - [MinScale]: The minimum scale of the camera.
|
||||
/// - [MaxScale]: The maximum scale of the camera.
|
||||
fn init_resources(mut commands: Commands) {
|
||||
commands.insert_resource(KeysMovementSettings {
|
||||
up: KeyCode::Z,
|
||||
|
@ -94,15 +100,15 @@ fn movement_system(
|
|||
}
|
||||
}
|
||||
|
||||
/// Scales the camera with mouse input.
|
||||
/// Scales the view with mouse input.
|
||||
fn scale_system(
|
||||
mut scroll_ev: EventReader<MouseWheel>,
|
||||
mut scroll_event: EventReader<MouseWheel>,
|
||||
mut query: Query<&mut OrthographicProjection, With<Camera>>,
|
||||
min_scale: Res<MinScale>,
|
||||
max_scale: Res<MaxScale>,
|
||||
scale_speed: Res<CameraSpeedScale>,
|
||||
) {
|
||||
for ev in scroll_ev.read() {
|
||||
for ev in scroll_event.read() {
|
||||
for mut projection in query.iter_mut() {
|
||||
if ev.unit != MouseScrollUnit::Line {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue
Not only...