
This is extracted out of eb8f973646476b4a4926ba644a77e2b3a5772159 and includes some additional changes to remove all references to AppBuilder and fix examples that still used App::build() instead of App::new(). In addition I didn't extract the sub app feature as it isn't ready yet. You can use `git diff --diff-filter=M eb8f973646476b4a4926ba644a77e2b3a5772159` to find all differences in this PR. The `--diff-filtered=M` filters all files added in the original commit but not in this commit away. Co-Authored-By: Carter Anderson <mcanders1@gmail.com>
37 lines
950 B
Rust
37 lines
950 B
Rust
use bevy::{input::touch::*, prelude::*};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_system(touch_system.system())
|
|
.run();
|
|
}
|
|
|
|
fn touch_system(touches: Res<Touches>) {
|
|
for touch in touches.iter_just_pressed() {
|
|
info!(
|
|
"just pressed touch with id: {:?}, at: {:?}",
|
|
touch.id(),
|
|
touch.position()
|
|
);
|
|
}
|
|
|
|
for touch in touches.iter_just_released() {
|
|
info!(
|
|
"just released touch with id: {:?}, at: {:?}",
|
|
touch.id(),
|
|
touch.position()
|
|
);
|
|
}
|
|
|
|
for touch in touches.iter_just_cancelled() {
|
|
info!("cancelled touch with id: {:?}", touch.id());
|
|
}
|
|
|
|
// you can also iterate all current touches and retrieve their state like this:
|
|
for touch in touches.iter() {
|
|
info!("active touch: {:?}", touch);
|
|
info!(" just_pressed: {}", touches.just_pressed(touch.id()));
|
|
}
|
|
}
|