diff --git a/examples/multiple.rs b/examples/multiple.rs index eccefcc..2b161f2 100644 --- a/examples/multiple.rs +++ b/examples/multiple.rs @@ -44,89 +44,76 @@ fn create_scene(mut cmd: Commands, asset_server: Res) { ..default() }) .insert(Player(50.)); + // Spawn Virtual Joystick on left - cmd.spawn( - VirtualJoystickBundle::new(VirtualJoystickNode { - border_image: asset_server.load("Horizontal_Outline_Arrows.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("Horizontal_Outline_Arrows.png"), + None, + None, + Some(Color::ORANGE_RED.with_a(0.3)), + Vec2::new(75., 75.), + Vec2::new(150., 150.), + VirtualJoystickNode { dead_zone: 0., id: JoystickController::MovementX, axis: VirtualJoystickAxis::Horizontal, behaviour: VirtualJoystickType::Fixed, - }) - .set_color(TintColor(Color::WHITE.with_a(0.2))) - .set_style(Style { + }, + Style { width: Val::Px(150.), height: Val::Px(150.), position_type: PositionType::Absolute, left: Val::Px(35.), bottom: Val::Percent(15.), ..default() - }), - ) - .insert(BackgroundColor(Color::ORANGE_RED.with_a(0.2))) - .insert(VirtualJoystickInteractionArea); + }, + ); // Spawn Virtual Joystick on Right - cmd.spawn( - VirtualJoystickBundle::new(VirtualJoystickNode { - border_image: asset_server.load("Vertical_Outline_Arrows.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("Vertical_Outline_Arrows.png"), + None, + None, + Some(Color::ORANGE_RED.with_a(0.3)), + Vec2::new(75., 75.), + Vec2::new(150., 150.), + VirtualJoystickNode { dead_zone: 0., id: JoystickController::MovementY, axis: VirtualJoystickAxis::Vertical, behaviour: VirtualJoystickType::Fixed, - }) - .set_color(TintColor(Color::WHITE.with_a(0.2))) - .set_style(Style { + }, + Style { width: Val::Px(150.), height: Val::Px(150.), position_type: PositionType::Absolute, right: Val::Px(35.), bottom: Val::Percent(15.), ..default() - }), - ) - .insert(BackgroundColor(Color::ORANGE_RED.with_a(0.2))) - .insert(VirtualJoystickInteractionArea); + }, + ); } fn update_joystick( mut joystick: EventReader>, - mut joystick_color: Query<(&mut TintColor, &VirtualJoystickNode)>, mut player: Query<(&mut Transform, &Player)>, - time_step: Res, + time_step: Res