Skip to content

Commit

Permalink
Merge pull request #107 from Aztro-dev/main
Browse files Browse the repository at this point in the history
Added text that explained how to use the example 'chain_3d'
  • Loading branch information
Jondolf authored Aug 6, 2023
2 parents e74e453 + d8df34d commit 6ec8bc4
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion crates/bevy_xpbd_3d/examples/chain_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
})
.insert_resource(SubstepCount(80))
.insert_resource(Gravity(Vector::NEG_Y * 9.81 * 2.0))
.add_systems(Startup, setup)
.add_systems(Startup, (setup, ui))
.add_systems(Update, movement)
.run();
}
Expand Down Expand Up @@ -95,3 +95,47 @@ fn movement(
linear_velocity.0 *= 0.9;
}
}

fn ui(mut commands: Commands) {
commands.spawn(Camera2dBundle {
camera: Camera {
order: -1,
..default()
},
..default()
});
commands
.spawn(NodeBundle {
style: Style {
width: Val::Percent(100.),
..default()
},
background_color: Color::rgba(0.15, 0.15, 0.15, 0.0).into(),
..default()
})
.with_children(|parent| {
// text
parent.spawn((
TextBundle::from_section(
"Use Arrow Keys to Move The Chain",
TextStyle {
font_size: 20.0,
color: Color::WHITE,
..default()
},
)
.with_style(Style {
margin: UiRect {
left: Val::Px(5.0),
top: Val::Px(30.0),
..default()
},
..default()
}),
// Because this is a distinct label widget and
// not button/list item text, this is necessary
// for accessibility to treat the text accordingly.
Label,
));
});
}

0 comments on commit 6ec8bc4

Please sign in to comment.