bevy/examples/input/mouse_input.rs

24 lines
634 B
Rust
Raw Normal View History

2020-06-04 23:49:36 -07:00
use bevy::prelude::*;
fn main() {
2021-04-11 13:13:07 -07:00
App::new()
.add_plugins(DefaultPlugins)
.add_system(mouse_click_system.system())
2020-06-04 23:49:36 -07:00
.run();
}
// This system prints messages when you press or release the left mouse button:
fn mouse_click_system(mouse_button_input: Res<Input<MouseButton>>) {
2020-06-04 23:57:39 -07:00
if mouse_button_input.pressed(MouseButton::Left) {
info!("left mouse currently pressed");
2020-06-04 23:57:39 -07:00
}
2020-06-15 12:47:35 -07:00
2020-06-04 23:49:36 -07:00
if mouse_button_input.just_pressed(MouseButton::Left) {
info!("left mouse just pressed");
2020-06-04 23:49:36 -07:00
}
if mouse_button_input.just_released(MouseButton::Left) {
info!("left mouse just released");
2020-06-04 23:49:36 -07:00
}
}