Crate bevy_touch_stick
source ·Expand description
Virtual touch screen analog joysticks for the Bevy game engine.
see the examples for more detailed usage
§Example
use bevy::prelude::*;
use bevy_touch_stick::prelude::*;
#[derive(Default, Reflect, Hash, Clone, PartialEq, Eq)]
enum Stick {
#[default]
Left,
Right,
}
fn main () {
App::new().add_systems(Startup, spawn_joystick).run()
}
fn spawn_joystick(mut commands: Commands) {
commands.spawn((
BackgroundColor(Color::BLUE),
TouchStickUiBundle {
stick: TouchStick {
id: Stick::Right,
stick_type: TouchStickType::Dynamic,
..default()
},
style: Style {
width: Val::Px(150.),
height: Val::Px(150.),
position_type: PositionType::Absolute,
right: Val::Px(35.),
bottom: Val::Percent(15.),
..default()
},
..default()
}
));
}
Modules§
- Commonly used exports from this crate
Structs§
- Pure data, independent of
bevy_ui
- Event sent whenever the
TouchStick
is interacted. - Mapping of a
TouchStick
to bevy gamepad axes. - Marker component for a
bevy_ui
Node area where sticks can be interacted with. - Plugin holding
TouchStick
functionality - Touch stick ui bundle for easy spawning
- Marker component
- Marker component
Enums§
- What action the
TouchStick
is experiencing - How the touch stick is positioned onscreen
Traits§
- Type definition for
TouchStick
identifier