From e7a43ea864de2fd66f9db59b7380fed2f784aaaa Mon Sep 17 00:00:00 2001 From: Sergio Ribera Date: Sat, 18 Nov 2023 15:53:48 -0400 Subject: [PATCH] docs: upgrade to bevy 0.12 --- README.md | 150 ++++++++++----------------------------------------- release.toml | 2 +- 2 files changed, 30 insertions(+), 122 deletions(-) diff --git a/README.md b/README.md index 8c12673..1e09e34 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Aviable and compatible versions | bevy | VirtualJoystick | |--------|-----------------| +| 0.12 | 2.0.1 | | 0.11 | 2.0.1 | | 0.10.1 | 1.1.2 | @@ -66,7 +67,7 @@ cargo run --example simple -F=inspect Add to Cargo.toml ```toml [dependencies] -bevy = "0.11" +bevy = "0.12" virtual_joystick = "*" # Add your version ``` @@ -115,150 +116,57 @@ fn create_scene(mut cmd: Commands, asset_server: Res) { cmd.spawn_empty().insert(Player(30.)); // Spawn Virtual Joystick at horizontal center - cmd.spawn( - // Define variable for Joystick - VirtualJoystickBundle::new(VirtualJoystickNode { - border_image: asset_server.load("Outline.png"), - knob_image: asset_server.load("Knob.png"), - knob_size: Vec2::new(80., 80.), + create_joystick( + &mut cmd, + asset_server.load("Knob.png"), + asset_server.load("Outline.png"), + None, + None, + Some(Color::ORANGE_RED.with_a(0.3)), + Vec2::new(75., 75.), + Vec2::new(150., 150.), + VirtualJoystickNode { dead_zone: 0., - id: JoystickControllerID::Joystick1, - axis: VirtualJoystickAxis::Horizontal, - behaviour: VirtualJoystickType::Fixed, - }) - .set_color(TintColor(Color::WHITE)) - .set_style(Style { - size: Size::all(Val::Px(150.)), + id: "UniqueJoystick".to_string(), + axis: VirtualJoystickAxis::Both, + behaviour: VirtualJoystickType::Floating, + }, + Style { + width: Val::Px(150.), + height: Val::Px(150.), position_type: PositionType::Absolute, - position: UiRect { - left: Val::Percent(50.), - bottom: Val::Percent(15.), - ..default() - }, + left: Val::Percent(50.), + bottom: Val::Percent(15.), ..default() - }), - ) - // When you add this component you mark this area as interactable for Joystick - .insert(VirtualJoystickInteractionArea); + }, + ); } ``` Use variable generated by Joystick ```rust - fn update_joystick( - mut joystick: EventReader>, + mut joystick: EventReader>, mut player: Query<(&mut Transform, &Player)>, - time_step: Res, + time_step: Res