部分集成的UI系统
commands.spawn((
SceneEntity,
Node {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
flex_direction: FlexDirection::Row,
..default()
},
GlobalZIndex(100),
children![
(
Node {
position_type: PositionType::Absolute,
width: Val::Percent(50.0),
height: Val::Percent(100.0),
align_items: AlignItems::Start,
justify_content: JustifyContent::Center,
flex_direction: FlexDirection::Column,
padding: UiRect {
left: Val::Px(50.0),
right: Val::Px(30.0),
top: Val::Px(0.0),
bottom: Val::Px(70.0),
},
row_gap: Val::Px(20.0),
..default()
},
ElementId("leftbox".to_string()),
children![
(
Text::new(logo_text),
TextFont {
font: assets.load("fonts/SarasaFixedHC-Regular.ttf"),
font_size: logo_font_size,
..default()
},
TextColor(logo_text_color),
Node {
margin: UiRect {
left: Val::Px(20.0),
right: Val::Px(0.0),
top: Val::Px(0.0),
bottom: Val::Px(0.0),
},
..default()
},
GlobalZIndex(110),
),
create_button(&assets, "开始游戏", StartGameButton),
create_button(&assets, "关于", AboutButton),
create_button(&assets, "帮助", HelpButton),
create_button(&assets, "退出", ExitGameButton),
],
),
(
Node {
width: Val::Percent(50.0),
height: Val::Percent(100.0),
..default()
},
),
],
));