Answers for "bevy input"

0

bevy input

pub fn my_system(keys: Res<Input<KeyCode>>, btns: Res<Input<MouseButton>>) {
    // Keyboard input
    if keys.pressed(KeyCode::Space) {
        eprintln!("space is being held down");
    }

    // Mouse buttons
    if btns.just_pressed(MouseButton::Left) {
        eprintln!("a left click just happened");
    }
}
Posted by: Guest on February-16-2021

Browse Popular Code Answers by Language