editor: move camera
This commit is contained in:
parent
02b29bd093
commit
5d2289d1c0
2 changed files with 20 additions and 0 deletions
|
@ -51,6 +51,12 @@ Skip to level `N: u32` with the command `bevyjam <N>`.
|
||||||
|
|
||||||
Edit the level `N: u32` with the command `bevyjam <N> e`.
|
Edit the level `N: u32` with the command `bevyjam <N> e`.
|
||||||
|
|
||||||
|
### Editor controls
|
||||||
|
|
||||||
|
* **Select handles**: left click to select, click in void to deselect, CTRL+click to select many, CTRL+A to select all
|
||||||
|
* **Move handles**: arrows to move one step, Shift+arrows to move continuously
|
||||||
|
* **Move camera**: CTRL+arrows
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
GNU AGPL v3, CopyLeft 2022 Pascal Engélibert, Nixon Cheng
|
GNU AGPL v3, CopyLeft 2022 Pascal Engélibert, Nixon Cheng
|
||||||
|
|
|
@ -184,9 +184,23 @@ fn setup(
|
||||||
|
|
||||||
fn keyboard_input_system(
|
fn keyboard_input_system(
|
||||||
keyboard_input: Res<Input<KeyCode>>,
|
keyboard_input: Res<Input<KeyCode>>,
|
||||||
|
mut camera_query: Query<&mut Transform, (With<Camera>, Without<Draggable>)>,
|
||||||
mut drag_query: Query<(&mut Transform, &Selection, Option<&End>), With<Draggable>>,
|
mut drag_query: Query<(&mut Transform, &Selection, Option<&End>), With<Draggable>>,
|
||||||
mut drag_end_event: EventWriter<DragEndEvent>,
|
mut drag_end_event: EventWriter<DragEndEvent>,
|
||||||
) {
|
) {
|
||||||
|
if keyboard_input.pressed(KeyCode::LControl) || keyboard_input.pressed(KeyCode::RControl) {
|
||||||
|
let mut transform = camera_query.single_mut();
|
||||||
|
let drag = Vec3 {
|
||||||
|
x: (keyboard_input.pressed(KeyCode::Right) as i8
|
||||||
|
- keyboard_input.pressed(KeyCode::Left) as i8) as _,
|
||||||
|
y: (keyboard_input.pressed(KeyCode::Up) as i8
|
||||||
|
- keyboard_input.pressed(KeyCode::Down) as i8) as _,
|
||||||
|
z: 0.,
|
||||||
|
} * 8.;
|
||||||
|
transform.translation += drag;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let drag = if keyboard_input.pressed(KeyCode::LShift) || keyboard_input.pressed(KeyCode::RShift)
|
let drag = if keyboard_input.pressed(KeyCode::LShift) || keyboard_input.pressed(KeyCode::RShift)
|
||||||
{
|
{
|
||||||
Vec3 {
|
Vec3 {
|
||||||
|
|
Loading…
Reference in a new issue