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§

prelude
Commonly used exports from this crate

Structs§

TouchStick
Pure data, independent of bevy_ui
TouchStickEvent
Event sent whenever the TouchStick is interacted.
TouchStickGamepadMapping
Mapping of a TouchStick to bevy gamepad axes.
TouchStickInteractionArea
Marker component for a bevy_ui Node area where sticks can be interacted with.
TouchStickPlugin
Plugin holding TouchStick functionality
TouchStickUiBundle
Touch stick ui bundle for easy spawning
TouchStickUiKnob
Marker component
TouchStickUiOutline
Marker component

Enums§

TouchStickEventType
What action the TouchStick is experiencing
TouchStickType
How the touch stick is positioned onscreen

Traits§

StickIdType
Type definition for TouchStick identifier