diff --git a/examples/simple.rs b/examples/simple.rs index 7af7dfd..4e444e4 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -58,7 +58,7 @@ fn create_scene(mut cmd: Commands, asset_server: Res) { ..default() }, (JoystickFloating), - NoAction + NoAction, ); } diff --git a/examples/tint.rs b/examples/tint.rs index 72cec01..47f2134 100644 --- a/examples/tint.rs +++ b/examples/tint.rs @@ -19,7 +19,7 @@ struct Player(pub f32); struct TintAction { down: Color, - up: Color + up: Color, } impl VirtualJoystickAction for TintAction { @@ -32,7 +32,9 @@ impl VirtualJoystickAction for TintAction { ) { let mut child_entities: Vec = Vec::new(); { - let Some(children) = world.get::(entity) else { return; }; + let Some(children) = world.get::(entity) else { + return; + }; for &child in children.iter() { child_entities.push(child); } @@ -40,9 +42,12 @@ impl VirtualJoystickAction for TintAction { for &child in &child_entities { let is_base_or_knob: bool; { - is_base_or_knob = world.get::(entity).is_some() || world.get::(entity).is_some(); + is_base_or_knob = world.get::(entity).is_some() + || world.get::(entity).is_some(); } - let Some(mut bg_color) = world.get_mut::(child) else { continue; }; + let Some(mut bg_color) = world.get_mut::(child) else { + continue; + }; bg_color.0 = self.down; } } @@ -56,7 +61,9 @@ impl VirtualJoystickAction for TintAction { ) { let mut child_entities: Vec = Vec::new(); { - let Some(children) = world.get::(entity) else { return; }; + let Some(children) = world.get::(entity) else { + return; + }; for &child in children.iter() { child_entities.push(child); } @@ -64,9 +71,12 @@ impl VirtualJoystickAction for TintAction { for &child in &child_entities { let is_base_or_knob: bool; { - is_base_or_knob = world.get::(entity).is_some() || world.get::(entity).is_some(); + is_base_or_knob = world.get::(entity).is_some() + || world.get::(entity).is_some(); } - let Some(mut bg_color) = world.get_mut::(child) else { continue; }; + let Some(mut bg_color) = world.get_mut::(child) else { + continue; + }; bg_color.0 = self.up; } } @@ -116,7 +126,7 @@ fn create_scene(mut cmd: Commands, asset_server: Res) { TintAction { down: Color::RED.with_a(1.0), up: Color::GREEN.with_a(0.5), - } + }, ); } diff --git a/src/action.rs b/src/action.rs index 649cf84..02f406b 100644 --- a/src/action.rs +++ b/src/action.rs @@ -13,14 +13,7 @@ pub trait VirtualJoystickAction: Send + Sync + 'static { _entity: Entity, ) { } - fn on_drag( - &self, - _id: I, - _data: VirtualJoystickState, - _world: &mut World, - _entity: Entity, - ) { - } + fn on_drag(&self, _id: I, _data: VirtualJoystickState, _world: &mut World, _entity: Entity) {} fn on_end_drag( &self, _id: I, diff --git a/src/behavior.rs b/src/behavior.rs index a4d1cd5..7af4dcb 100644 --- a/src/behavior.rs +++ b/src/behavior.rs @@ -1,6 +1,14 @@ use std::sync::Arc; -use bevy::{ecs::{all_tuples, entity::Entity, world::World}, hierarchy::Children, math::{Rect, Vec2}, reflect::Reflect, render::view::Visibility, transform::components::GlobalTransform, ui::Node}; +use bevy::{ + ecs::{all_tuples, entity::Entity, world::World}, + hierarchy::Children, + math::{Rect, Vec2}, + reflect::Reflect, + render::view::Visibility, + transform::components::GlobalTransform, + ui::Node, +}; use crate::{components::VirtualJoystickState, VirtualJoystickUIBackground}; @@ -70,7 +78,9 @@ pub struct JoystickDynamic; impl VirtualJoystickBehavior for JoystickDeadZone { fn update_at_constraint_stage(&self, world: &mut World, entity: Entity) { - let Some(mut joystick_state) = world.get_mut::(entity) else { return; }; + let Some(mut joystick_state) = world.get_mut::(entity) else { + return; + }; let dead_zone = self.0; if joystick_state.delta.x.abs() < dead_zone { joystick_state.delta.x = 0.0; @@ -83,14 +93,18 @@ impl VirtualJoystickBehavior for JoystickDeadZone { impl VirtualJoystickBehavior for JoystickHorizontalOnly { fn update_at_constraint_stage(&self, world: &mut World, entity: Entity) { - let Some(mut joystick_state) = world.get_mut::(entity) else { return; }; + let Some(mut joystick_state) = world.get_mut::(entity) else { + return; + }; joystick_state.delta.y = 0.0; } } impl VirtualJoystickBehavior for JoystickVerticalOnly { fn update_at_constraint_stage(&self, world: &mut World, entity: Entity) { - let Some(mut joystick_state) = world.get_mut::(entity) else { return; }; + let Some(mut joystick_state) = world.get_mut::(entity) else { + return; + }; joystick_state.delta.x = 0.0; } } @@ -98,9 +112,15 @@ impl VirtualJoystickBehavior for JoystickVerticalOnly { impl VirtualJoystickBehavior for JoystickInvisible { fn update(&self, world: &mut World, entity: Entity) { let joystick_state = world.get::(entity).map(|x| x.clone()); - let Some(joystick_state) = joystick_state else { return; }; - let Some(mut joystick_visibility) = world.get_mut::(entity) else { return; }; - if joystick_state.just_released || *joystick_visibility != Visibility::Hidden && joystick_state.touch_state.is_none() { + let Some(joystick_state) = joystick_state else { + return; + }; + let Some(mut joystick_visibility) = world.get_mut::(entity) else { + return; + }; + if joystick_state.just_released + || *joystick_visibility != Visibility::Hidden && joystick_state.touch_state.is_none() + { *joystick_visibility = Visibility::Hidden; } if let Some(touch_state) = &joystick_state.touch_state { @@ -115,21 +135,34 @@ impl VirtualJoystickBehavior for JoystickFixed { fn update_at_delta_stage(&self, world: &mut World, entity: Entity) { let mut children_entities: Vec = Vec::new(); { - let Some(children) = world.get::(entity) else { return; }; + let Some(children) = world.get::(entity) else { + return; + }; for &child in children.iter() { children_entities.push(child); } } let mut joystick_base_rect: Option = None; for &child in &children_entities { - if world.get::(child).is_none() { continue; } - let Some(joystick_base_node) = world.get::(child) else { continue; }; - let Some(joystick_base_global_transform) = world.get::(child) else { continue; }; - joystick_base_rect = Some(joystick_base_node.logical_rect(joystick_base_global_transform)); + if world.get::(child).is_none() { + continue; + } + let Some(joystick_base_node) = world.get::(child) else { + continue; + }; + let Some(joystick_base_global_transform) = world.get::(child) else { + continue; + }; + joystick_base_rect = + Some(joystick_base_node.logical_rect(joystick_base_global_transform)); break; } - let Some(joystick_base_rect) = joystick_base_rect else { return; }; - let Some(mut joystick_state) = world.get_mut::(entity) else { return; }; + let Some(joystick_base_rect) = joystick_base_rect else { + return; + }; + let Some(mut joystick_state) = world.get_mut::(entity) else { + return; + }; joystick_state.base_offset = Vec2::ZERO; let new_delta: Vec2; if let Some(touch_state) = &joystick_state.touch_state { @@ -149,21 +182,34 @@ impl VirtualJoystickBehavior for JoystickFloating { fn update_at_delta_stage(&self, world: &mut World, entity: Entity) { let mut children_entities: Vec = Vec::new(); { - let Some(children) = world.get::(entity) else { return; }; + let Some(children) = world.get::(entity) else { + return; + }; for &child in children.iter() { children_entities.push(child); } } let mut joystick_base_rect: Option = None; for &child in &children_entities { - if world.get::(child).is_none() { continue; } - let Some(joystick_base_node) = world.get::(child) else { continue; }; - let Some(joystick_base_global_transform) = world.get::(child) else { continue; }; - joystick_base_rect = Some(joystick_base_node.logical_rect(joystick_base_global_transform)); + if world.get::(child).is_none() { + continue; + } + let Some(joystick_base_node) = world.get::(child) else { + continue; + }; + let Some(joystick_base_global_transform) = world.get::(child) else { + continue; + }; + joystick_base_rect = + Some(joystick_base_node.logical_rect(joystick_base_global_transform)); break; } - let Some(joystick_base_rect) = joystick_base_rect else { return; }; - let Some(mut joystick_state) = world.get_mut::(entity) else { return; }; + let Some(joystick_base_rect) = joystick_base_rect else { + return; + }; + let Some(mut joystick_state) = world.get_mut::(entity) else { + return; + }; let base_offset: Vec2; let mut assign_base_offset = false; if let Some(touch_state) = &joystick_state.touch_state { @@ -200,27 +246,44 @@ impl VirtualJoystickBehavior for JoystickDynamic { fn update_at_delta_stage(&self, world: &mut World, entity: Entity) { let joystick_rect: Rect; { - let Some(joystick_node) = world.get::(entity) else { return; }; - let Some(joystick_global_transform) = world.get::(entity) else { return; }; + let Some(joystick_node) = world.get::(entity) else { + return; + }; + let Some(joystick_global_transform) = world.get::(entity) else { + return; + }; joystick_rect = joystick_node.logical_rect(joystick_global_transform); } let mut children_entities: Vec = Vec::new(); { - let Some(children) = world.get::(entity) else { return; }; + let Some(children) = world.get::(entity) else { + return; + }; for &child in children.iter() { children_entities.push(child); } } let mut joystick_base_rect: Option = None; for &child in &children_entities { - if world.get::(child).is_none() { continue; } - let Some(joystick_base_node) = world.get::(child) else { continue; }; - let Some(joystick_base_global_transform) = world.get::(child) else { continue; }; - joystick_base_rect = Some(joystick_base_node.logical_rect(joystick_base_global_transform)); + if world.get::(child).is_none() { + continue; + } + let Some(joystick_base_node) = world.get::(child) else { + continue; + }; + let Some(joystick_base_global_transform) = world.get::(child) else { + continue; + }; + joystick_base_rect = + Some(joystick_base_node.logical_rect(joystick_base_global_transform)); break; } - let Some(joystick_base_rect) = joystick_base_rect else { return; }; - let Some(mut joystick_state) = world.get_mut::(entity) else { return; }; + let Some(joystick_base_rect) = joystick_base_rect else { + return; + }; + let Some(mut joystick_state) = world.get_mut::(entity) else { + return; + }; let joystick_base_rect_center = joystick_base_rect.center(); let joystick_base_rect_half_size = joystick_base_rect.half_size(); let base_offset: Vec2; @@ -244,9 +307,13 @@ impl VirtualJoystickBehavior for JoystickDynamic { let new_delta: Vec2; let mut new_base_offset: Option = None; if let Some(touch_state) = &joystick_state.touch_state { - let mut offset = touch_state.current - (joystick_rect.min + base_offset + joystick_base_rect.half_size()); - if offset.length_squared() > joystick_base_rect_half_size.x * joystick_base_rect_half_size.x { - let adjustment = offset - offset * (joystick_base_rect_half_size.x / offset.length()); + let mut offset = touch_state.current + - (joystick_rect.min + base_offset + joystick_base_rect.half_size()); + if offset.length_squared() + > joystick_base_rect_half_size.x * joystick_base_rect_half_size.x + { + let adjustment = + offset - offset * (joystick_base_rect_half_size.x / offset.length()); offset += adjustment; new_base_offset = Some(base_offset + adjustment); } diff --git a/src/components.rs b/src/components.rs index 33a3cf2..874c8c7 100644 --- a/src/components.rs +++ b/src/components.rs @@ -10,7 +10,10 @@ use bevy_inspector_egui::prelude::ReflectInspectorOptions; #[cfg(feature = "inspect")] use bevy_inspector_egui::InspectorOptions; -use crate::{action::NoAction, behavior::JoystickFloating, VirtualJoystickAction, VirtualJoystickBehavior, VirtualJoystickID}; +use crate::{ + action::NoAction, behavior::JoystickFloating, VirtualJoystickAction, VirtualJoystickBehavior, + VirtualJoystickID, +}; #[derive(Component, Copy, Clone, Debug, Default, Reflect)] #[reflect(Component, Default)] @@ -31,18 +34,24 @@ pub struct VirtualJoystickNode { #[reflect(ignore)] pub behavior: Arc, #[reflect(ignore)] - pub action: Arc> + pub action: Arc>, } impl Default for VirtualJoystickNode { fn default() -> Self { - Self { id: Default::default(), behavior: Arc::new(JoystickFloating), action: Arc::new(NoAction::default()), } + Self { + id: Default::default(), + behavior: Arc::new(JoystickFloating), + action: Arc::new(NoAction::default()), + } } } impl std::fmt::Debug for VirtualJoystickNode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("VirtualJoystickNode").field("id", &self.id).finish() + f.debug_struct("VirtualJoystickNode") + .field("id", &self.id) + .finish() } } diff --git a/src/lib.rs b/src/lib.rs index 06ddc87..d1404fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,14 +10,17 @@ mod systems; mod utils; pub use action::{NoAction, VirtualJoystickAction}; -pub use behavior::{VirtualJoystickBehavior, JoystickDeadZone, JoystickHorizontalOnly, JoystickVerticalOnly, JoystickInvisible, JoystickFixed, JoystickFloating, JoystickDynamic}; +pub use behavior::{ + JoystickDeadZone, JoystickDynamic, JoystickFixed, JoystickFloating, JoystickHorizontalOnly, + JoystickInvisible, JoystickVerticalOnly, VirtualJoystickBehavior, +}; pub use bundles::VirtualJoystickBundle; pub use components::{ - VirtualJoystickNode, VirtualJoystickState, VirtualJoystickUIBackground, - VirtualJoystickUIKnob, + VirtualJoystickNode, VirtualJoystickState, VirtualJoystickUIBackground, VirtualJoystickUIKnob, }; use systems::{ - update_action, update_behavior, update_behavior_constraints, update_behavior_knob_delta, update_fire_events, update_input, update_missing_state, update_ui + update_action, update_behavior, update_behavior_constraints, update_behavior_knob_delta, + update_fire_events, update_input, update_missing_state, update_ui, }; pub use utils::create_joystick; @@ -50,8 +53,18 @@ pub trait VirtualJoystickID: { } -impl - VirtualJoystickID for S +impl< + S: Hash + + Sync + + Send + + Clone + + std::fmt::Debug + + Default + + Reflect + + FromReflect + + TypePath + + 'static, + > VirtualJoystickID for S { } @@ -61,20 +74,20 @@ impl Plugin for VirtualJoystickPlugin { .register_type::() .add_event::>() .add_event::() - .add_systems(PreUpdate, ( - update_missing_state::, - update_input.after(update_missing_state::), - )) .add_systems( - UpdateKnobDelta, - update_behavior_knob_delta::, + PreUpdate, + ( + update_missing_state::, + update_input.after(update_missing_state::), + ), ) + .add_systems(UpdateKnobDelta, update_behavior_knob_delta::) + .add_systems(ConstrainKnobDelta, update_behavior_constraints::) + .add_systems(FireEvents, update_fire_events::) .add_systems( - ConstrainKnobDelta, - update_behavior_constraints::, + UpdateUI, + (update_behavior::, update_action::, update_ui), ) - .add_systems(FireEvents, update_fire_events::) - .add_systems(UpdateUI, (update_behavior::, update_action::, update_ui)) .add_systems(Update, |world: &mut World| { world.run_schedule(UpdateKnobDelta); world.run_schedule(ConstrainKnobDelta); diff --git a/src/systems.rs b/src/systems.rs index 050078c..30093d0 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -2,17 +2,30 @@ use std::sync::Arc; use bevy::{ ecs::{ - entity::Entity, event::EventWriter, query::With, system::{Query, Res}, world::World - }, hierarchy::Children, input::{mouse::MouseButton, touch::Touches, ButtonInput}, math::{Rect, Vec2}, transform::components::GlobalTransform, ui::{Node, PositionType, Style, Val}, window::{PrimaryWindow, Window} + entity::Entity, + event::EventWriter, + query::With, + system::{Query, Res}, + world::World, + }, + hierarchy::Children, + input::{mouse::MouseButton, touch::Touches, ButtonInput}, + math::{Rect, Vec2}, + transform::components::GlobalTransform, + ui::{Node, PositionType, Style, Val}, + window::{PrimaryWindow, Window}, }; use crate::{ - components::{TouchState, VirtualJoystickState, VirtualJoystickUIBackground, VirtualJoystickUIKnob}, VirtualJoystickEvent, VirtualJoystickEventType, VirtualJoystickID, VirtualJoystickNode + components::{ + TouchState, VirtualJoystickState, VirtualJoystickUIBackground, VirtualJoystickUIKnob, + }, + VirtualJoystickEvent, VirtualJoystickEventType, VirtualJoystickID, VirtualJoystickNode, }; use bevy::ecs::query::Without; pub fn update_missing_state(world: &mut World) { - let mut joysticks = world.query::<(Entity,&VirtualJoystickNode)>(); + let mut joysticks = world.query::<(Entity, &VirtualJoystickNode)>(); let mut joystick_entities: Vec = Vec::new(); for (joystick_entity, _) in joysticks.iter(world) { joystick_entities.push(joystick_entity); @@ -20,7 +33,9 @@ pub fn update_missing_state(world: &mut World) { for joystick_entity in joystick_entities { let has_state = world.get::(joystick_entity).is_some(); if !has_state { - world.entity_mut(joystick_entity).insert(VirtualJoystickState::default()); + world + .entity_mut(joystick_entity) + .insert(VirtualJoystickState::default()); } } } @@ -96,7 +111,7 @@ pub fn update_input( } pub fn update_behavior_knob_delta(world: &mut World) { - let mut joysticks = world.query::<(Entity,&VirtualJoystickNode)>(); + let mut joysticks = world.query::<(Entity, &VirtualJoystickNode)>(); let mut joystick_entities: Vec = Vec::new(); for (joystick_entity, _) in joysticks.iter(world) { joystick_entities.push(joystick_entity); @@ -104,7 +119,10 @@ pub fn update_behavior_knob_delta(world: &mut World) { for joystick_entity in joystick_entities { let behavior; { - let Some(virtual_joystick_node) = world.get::>(joystick_entity) else { continue; }; + let Some(virtual_joystick_node) = world.get::>(joystick_entity) + else { + continue; + }; behavior = Arc::clone(&virtual_joystick_node.behavior); } behavior.update_at_delta_stage(world, joystick_entity); @@ -112,7 +130,7 @@ pub fn update_behavior_knob_delta(world: &mut World) { } pub fn update_behavior_constraints(world: &mut World) { - let mut joysticks = world.query::<(Entity,&VirtualJoystickNode)>(); + let mut joysticks = world.query::<(Entity, &VirtualJoystickNode)>(); let mut joystick_entities: Vec = Vec::new(); for (joystick_entity, _) in joysticks.iter(world) { joystick_entities.push(joystick_entity); @@ -120,7 +138,10 @@ pub fn update_behavior_constraints(world: &mut World) { for joystick_entity in joystick_entities { let behavior; { - let Some(virtual_joystick_node) = world.get::>(joystick_entity) else { continue; }; + let Some(virtual_joystick_node) = world.get::>(joystick_entity) + else { + continue; + }; behavior = Arc::clone(&virtual_joystick_node.behavior); } behavior.update_at_constraint_stage(world, joystick_entity); @@ -128,7 +149,7 @@ pub fn update_behavior_constraints(world: &mut World) { } pub fn update_behavior(world: &mut World) { - let mut joysticks = world.query::<(Entity,&VirtualJoystickNode)>(); + let mut joysticks = world.query::<(Entity, &VirtualJoystickNode)>(); let mut joystick_entities: Vec = Vec::new(); for (joystick_entity, _) in joysticks.iter(world) { joystick_entities.push(joystick_entity); @@ -136,7 +157,10 @@ pub fn update_behavior(world: &mut World) { for joystick_entity in joystick_entities { let behavior; { - let Some(virtual_joystick_node) = world.get::>(joystick_entity) else { continue; }; + let Some(virtual_joystick_node) = world.get::>(joystick_entity) + else { + continue; + }; behavior = Arc::clone(&virtual_joystick_node.behavior); } behavior.update(world, joystick_entity); @@ -144,7 +168,8 @@ pub fn update_behavior(world: &mut World) { } pub fn update_action(world: &mut World) { - let mut joysticks = world.query::<(Entity,&VirtualJoystickNode,&mut VirtualJoystickState)>(); + let mut joysticks = + world.query::<(Entity, &VirtualJoystickNode, &mut VirtualJoystickState)>(); let mut joystick_entities: Vec = Vec::new(); for (joystick_entity, _, _) in joysticks.iter(world) { joystick_entities.push(joystick_entity); @@ -157,7 +182,9 @@ pub fn update_action(world: &mut World) { for joystick_entity in joystick_entities { let drag_action: Option; { - let Some(joystick_state) = world.get::(joystick_entity) else { continue; }; + let Some(joystick_state) = world.get::(joystick_entity) else { + continue; + }; if joystick_state.just_released { drag_action = Some(DragAction::OnEndDrag); } else if let Some(touch_state) = &joystick_state.touch_state { @@ -170,12 +197,18 @@ pub fn update_action(world: &mut World) { drag_action = None; } } - let Some(drag_action) = drag_action else { continue; }; + let Some(drag_action) = drag_action else { + continue; + }; let id; let action; let joystick_state; { - let Ok((_, virtual_joystick_node, joystick_state_2)) = joysticks.get_mut(world, joystick_entity) else { continue; }; + let Ok((_, virtual_joystick_node, joystick_state_2)) = + joysticks.get_mut(world, joystick_entity) + else { + continue; + }; id = virtual_joystick_node.id.clone(); action = Arc::clone(&virtual_joystick_node.action); joystick_state = joystick_state_2.clone(); @@ -183,19 +216,19 @@ pub fn update_action(world: &mut World) { match drag_action { DragAction::OnStartDrag => { action.on_start_drag(id, joystick_state, world, joystick_entity); - }, + } DragAction::OnDrag => { action.on_drag(id, joystick_state, world, joystick_entity); - }, + } DragAction::OnEndDrag => { action.on_end_drag(id, joystick_state, world, joystick_entity); - }, + } } } } pub fn update_fire_events( - joysticks: Query<(&VirtualJoystickNode,&VirtualJoystickState)>, + joysticks: Query<(&VirtualJoystickNode, &VirtualJoystickState)>, mut send_values: EventWriter>, ) { for (joystick, joystick_state) in &joysticks { @@ -230,7 +263,10 @@ pub fn update_fire_events( #[allow(clippy::complexity)] pub fn update_ui( joysticks: Query<(&VirtualJoystickState, &Children)>, - mut joystick_bases: Query<(&mut Style, &Node, &GlobalTransform), With>, + mut joystick_bases: Query< + (&mut Style, &Node, &GlobalTransform), + With, + >, mut joystick_knobs: Query< (&mut Style, &Node, &GlobalTransform), ( @@ -239,15 +275,17 @@ pub fn update_ui( ), >, ) { - for (joystick_state, children) in &joysticks { + for (joystick_state, children) in &joysticks { let mut joystick_base_rect: Option = None; for child in children.iter() { if joystick_bases.contains(*child) { - let (mut joystick_base_style, joystick_base_node, joystick_base_global_transform) = joystick_bases.get_mut(*child).unwrap(); + let (mut joystick_base_style, joystick_base_node, joystick_base_global_transform) = + joystick_bases.get_mut(*child).unwrap(); joystick_base_style.position_type = PositionType::Absolute; joystick_base_style.left = Val::Px(joystick_state.base_offset.x); joystick_base_style.top = Val::Px(joystick_state.base_offset.y); - joystick_base_rect = Some(joystick_base_node.logical_rect(joystick_base_global_transform)); + joystick_base_rect = + Some(joystick_base_node.logical_rect(joystick_base_global_transform)); } } if joystick_base_rect.is_none() { diff --git a/src/utils.rs b/src/utils.rs index f8eb23d..03c1dcb 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,7 +1,8 @@ use bevy::prelude::*; use crate::{ - VirtualJoystickAction, VirtualJoystickBehavior, VirtualJoystickBundle, VirtualJoystickID, VirtualJoystickNode, VirtualJoystickUIBackground, VirtualJoystickUIKnob + VirtualJoystickAction, VirtualJoystickBehavior, VirtualJoystickBundle, VirtualJoystickID, + VirtualJoystickNode, VirtualJoystickUIBackground, VirtualJoystickUIKnob, }; /// This function is a simple helper to create a joystick @@ -115,9 +116,9 @@ pub fn create_joystick( VirtualJoystickNode::::default() .with_id(id) .with_behavior(behavior) - .with_action(action) - ) - .set_style(joystick_node_style), + .with_action(action), + ) + .set_style(joystick_node_style), ); let spawn = spawn.with_children(|parent| { parent.spawn((