diff --git a/examples/state/computed_states.rs b/examples/state/computed_states.rs index 4c5ea224e3..048a96eda3 100644 --- a/examples/state/computed_states.rs +++ b/examples/state/computed_states.rs @@ -336,19 +336,19 @@ mod ui { pub fn setup_menu(mut commands: Commands, tutorial_state: Res>) { let button_entity = commands - .spawn(Node { - // center button - width: Val::Percent(100.), - height: Val::Percent(100.), - justify_content: JustifyContent::Center, - align_items: AlignItems::Center, - flex_direction: FlexDirection::Column, - row_gap: Val::Px(10.), - ..default() - }) - .with_children(|parent| { - parent - .spawn(( + .spawn(( + Node { + // center button + width: Val::Percent(100.), + height: Val::Percent(100.), + justify_content: JustifyContent::Center, + align_items: AlignItems::Center, + flex_direction: FlexDirection::Column, + row_gap: Val::Px(10.), + ..default() + }, + children![ + ( Button, Node { width: Val::Px(200.), @@ -361,20 +361,16 @@ mod ui { }, BackgroundColor(NORMAL_BUTTON), MenuButton::Play, - )) - .with_children(|parent| { - parent.spawn(( + children![( Text::new("Play"), TextFont { font_size: 33.0, ..default() }, TextColor(Color::srgb(0.9, 0.9, 0.9)), - )); - }); - - parent - .spawn(( + )], + ), + ( Button, Node { width: Val::Px(200.), @@ -390,18 +386,17 @@ mod ui { TutorialState::Inactive => NORMAL_BUTTON, }), MenuButton::Tutorial, - )) - .with_children(|parent| { - parent.spawn(( + children![( Text::new("Tutorial"), TextFont { font_size: 33.0, ..default() }, TextColor(Color::srgb(0.9, 0.9, 0.9)), - )); - }); - }) + )] + ), + ], + )) .id(); commands.insert_resource(MenuData { root_entity: button_entity, @@ -453,75 +448,66 @@ mod ui { pub fn setup_paused_screen(mut commands: Commands) { info!("Printing Pause"); - commands - .spawn(( - StateScoped(IsPaused::Paused), + commands.spawn(( + StateScoped(IsPaused::Paused), + Node { + // center button + width: Val::Percent(100.), + height: Val::Percent(100.), + justify_content: JustifyContent::Center, + align_items: AlignItems::Center, + flex_direction: FlexDirection::Column, + row_gap: Val::Px(10.), + position_type: PositionType::Absolute, + ..default() + }, + children![( Node { - // center button - width: Val::Percent(100.), - height: Val::Percent(100.), + width: Val::Px(400.), + height: Val::Px(400.), + // horizontally center child text justify_content: JustifyContent::Center, + // vertically center child text align_items: AlignItems::Center, - flex_direction: FlexDirection::Column, - row_gap: Val::Px(10.), - position_type: PositionType::Absolute, ..default() }, - )) - .with_children(|parent| { - parent - .spawn(( - Node { - width: Val::Px(400.), - height: Val::Px(400.), - // horizontally center child text - justify_content: JustifyContent::Center, - // vertically center child text - align_items: AlignItems::Center, - ..default() - }, - BackgroundColor(NORMAL_BUTTON), - MenuButton::Play, - )) - .with_children(|parent| { - parent.spawn(( - Text::new("Paused"), - TextFont { - font_size: 33.0, - ..default() - }, - TextColor(Color::srgb(0.9, 0.9, 0.9)), - )); - }); - }); - } - - pub fn setup_turbo_text(mut commands: Commands) { - commands - .spawn(( - StateScoped(TurboMode), - Node { - // center button - width: Val::Percent(100.), - height: Val::Percent(100.), - justify_content: JustifyContent::Start, - align_items: AlignItems::Center, - flex_direction: FlexDirection::Column, - row_gap: Val::Px(10.), - position_type: PositionType::Absolute, - ..default() - }, - )) - .with_children(|parent| { - parent.spawn(( - Text::new("TURBO MODE"), + BackgroundColor(NORMAL_BUTTON), + MenuButton::Play, + children![( + Text::new("Paused"), TextFont { font_size: 33.0, ..default() }, - TextColor(Color::srgb(0.9, 0.3, 0.1)), - )); - }); + TextColor(Color::srgb(0.9, 0.9, 0.9)), + )], + ),], + )); + } + + pub fn setup_turbo_text(mut commands: Commands) { + commands.spawn(( + StateScoped(TurboMode), + Node { + // center button + width: Val::Percent(100.), + height: Val::Percent(100.), + justify_content: JustifyContent::Start, + align_items: AlignItems::Center, + flex_direction: FlexDirection::Column, + row_gap: Val::Px(10.), + position_type: PositionType::Absolute, + ..default() + }, + children![( + Text::new("TURBO MODE"), + TextFont { + font_size: 33.0, + ..default() + }, + TextColor(Color::srgb(0.9, 0.3, 0.1)), + )], + )); } pub fn change_color(time: Res