From d0f453c12b27f8c7b95e85bffae25ce69fbcf640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 3 Jun 2024 23:13:37 +0200 Subject: [PATCH] use in example --- examples/mobile/src/lib.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/mobile/src/lib.rs b/examples/mobile/src/lib.rs index 45a89a076c8ac..87c815dfb42b6 100644 --- a/examples/mobile/src/lib.rs +++ b/examples/mobile/src/lib.rs @@ -2,7 +2,7 @@ use bevy::{ color::palettes::basic::*, - input::touch::TouchPhase, + input::{gestures::RotationGesture, touch::TouchPhase}, prelude::*, window::{AppLifecycle, WindowMode}, }; @@ -15,6 +15,9 @@ fn main() { primary_window: Some(Window { resizable: false, mode: WindowMode::BorderlessFullscreen, + // on iOS, gestures must be enabled. + // This doesn't work on Android + recognize_rotation_gesture: true, ..default() }), ..default() @@ -35,6 +38,7 @@ fn touch_camera( mut touches: EventReader, mut camera: Query<&mut Transform, With>, mut last_position: Local>, + mut rotations: EventReader, ) { let window = windows.single(); @@ -55,6 +59,12 @@ fn touch_camera( } *last_position = Some(touch.position); } + /// Rotation gestures only work on iOS + for rotation in rotations.read() { + let mut transform = camera.single_mut(); + let forward = transform.forward(); + transform.rotate_axis(forward, rotation.0 / 10.0) + } } /// set up a simple 3D scene