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§

Enums§

Traits§