Skip to content

Commit

Permalink
Replace uses of entity.insert with tuple bundles in game_menu exa…
Browse files Browse the repository at this point in the history
…mple (bevyengine#9619)

# Objective

Change two places where `entity.insert` is used to add components
individually to spawn a tuple bundle instead.
  • Loading branch information
ickshonpe authored and Ray Redondo committed Jan 9, 2024
1 parent c045e27 commit 11112ab
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions examples/games/game_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,16 +654,19 @@ mod menu {
DisplayQuality::Medium,
DisplayQuality::High,
] {
let mut entity = parent.spawn(ButtonBundle {
style: Style {
width: Val::Px(150.0),
height: Val::Px(65.0),
..button_style.clone()
let mut entity = parent.spawn((
ButtonBundle {
style: Style {
width: Val::Px(150.0),
height: Val::Px(65.0),
..button_style.clone()
},
background_color: NORMAL_BUTTON.into(),
..default()
},
background_color: NORMAL_BUTTON.into(),
..default()
});
entity.insert(quality_setting).with_children(|parent| {
quality_setting,
));
entity.with_children(|parent| {
parent.spawn(TextBundle::from_section(
format!("{quality_setting:?}"),
button_text_style.clone(),
Expand Down Expand Up @@ -746,16 +749,18 @@ mod menu {
button_text_style.clone(),
));
for volume_setting in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] {
let mut entity = parent.spawn(ButtonBundle {
style: Style {
width: Val::Px(30.0),
height: Val::Px(65.0),
..button_style.clone()
let mut entity = parent.spawn((
ButtonBundle {
style: Style {
width: Val::Px(30.0),
height: Val::Px(65.0),
..button_style.clone()
},
background_color: NORMAL_BUTTON.into(),
..default()
},
background_color: NORMAL_BUTTON.into(),
..default()
});
entity.insert(Volume(volume_setting));
Volume(volume_setting),
));
if *volume == Volume(volume_setting) {
entity.insert(SelectedOption);
}
Expand Down

0 comments on commit 11112ab

Please sign in to comment.