bevy/examples/input/touch_input.rs
Benjamin Brienen 64efd08e13
Prefer Display over Debug (#16112)
# Objective

Fixes #16104

## Solution

I removed all instances of `:?` and put them back one by one where it
caused an error.

I removed some bevy_utils helper functions that were only used in 2
places and don't add value. See: #11478

## Testing

CI should catch the mistakes

## Migration Guide

`bevy::utils::{dbg,info,warn,error}` were removed. Use
`bevy::utils::tracing::{debug,info,warn,error}` instead.

---------

Co-authored-by: SpecificProtagonist <vincentjunge@posteo.net>
2024-12-27 00:40:06 +00:00

39 lines
988 B
Rust

//! Displays touch presses, releases, and cancels.
use bevy::{input::touch::*, prelude::*};
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Update, touch_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_canceled() {
info!("canceled 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()));
}
}