Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added text that explained how to use the example 'chain_3d' #107

Merged
merged 4 commits into from
Aug 6, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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::Percent(0.5),
top: Val::Percent(2.0),
Aztro-dev marked this conversation as resolved.
Show resolved Hide resolved
..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,
));
});
}