@@ -336,19 +336,19 @@ mod ui {
336
336
337
337
pub fn setup_menu ( mut commands : Commands , tutorial_state : Res < State < TutorialState > > ) {
338
338
let button_entity = commands
339
- . spawn ( Node {
340
- // center button
341
- width : Val :: Percent ( 100. ) ,
342
- height : Val :: Percent ( 100. ) ,
343
- justify_content : JustifyContent :: Center ,
344
- align_items : AlignItems :: Center ,
345
- flex_direction : FlexDirection :: Column ,
346
- row_gap : Val :: Px ( 10. ) ,
347
- .. default ( )
348
- } )
349
- . with_children ( |parent| {
350
- parent
351
- . spawn ( (
339
+ . spawn ( (
340
+ Node {
341
+ // center button
342
+ width : Val :: Percent ( 100. ) ,
343
+ height : Val :: Percent ( 100. ) ,
344
+ justify_content : JustifyContent :: Center ,
345
+ align_items : AlignItems :: Center ,
346
+ flex_direction : FlexDirection :: Column ,
347
+ row_gap : Val :: Px ( 10. ) ,
348
+ .. default ( )
349
+ } ,
350
+ children ! [
351
+ (
352
352
Button ,
353
353
Node {
354
354
width: Val :: Px ( 200. ) ,
@@ -361,20 +361,16 @@ mod ui {
361
361
} ,
362
362
BackgroundColor ( NORMAL_BUTTON ) ,
363
363
MenuButton :: Play ,
364
- ) )
365
- . with_children ( |parent| {
366
- parent. spawn ( (
364
+ children![ (
367
365
Text :: new( "Play" ) ,
368
366
TextFont {
369
367
font_size: 33.0 ,
370
368
..default ( )
371
369
} ,
372
370
TextColor ( Color :: srgb( 0.9 , 0.9 , 0.9 ) ) ,
373
- ) ) ;
374
- } ) ;
375
-
376
- parent
377
- . spawn ( (
371
+ ) ] ,
372
+ ) ,
373
+ (
378
374
Button ,
379
375
Node {
380
376
width: Val :: Px ( 200. ) ,
@@ -390,18 +386,17 @@ mod ui {
390
386
TutorialState :: Inactive => NORMAL_BUTTON ,
391
387
} ) ,
392
388
MenuButton :: Tutorial ,
393
- ) )
394
- . with_children ( |parent| {
395
- parent. spawn ( (
389
+ children![ (
396
390
Text :: new( "Tutorial" ) ,
397
391
TextFont {
398
392
font_size: 33.0 ,
399
393
..default ( )
400
394
} ,
401
395
TextColor ( Color :: srgb( 0.9 , 0.9 , 0.9 ) ) ,
402
- ) ) ;
403
- } ) ;
404
- } )
396
+ ) ]
397
+ ) ,
398
+ ] ,
399
+ ) )
405
400
. id ( ) ;
406
401
commands. insert_resource ( MenuData {
407
402
root_entity : button_entity,
@@ -453,75 +448,66 @@ mod ui {
453
448
454
449
pub fn setup_paused_screen ( mut commands : Commands ) {
455
450
info ! ( "Printing Pause" ) ;
456
- commands
457
- . spawn ( (
458
- StateScoped ( IsPaused :: Paused ) ,
451
+ commands. spawn ( (
452
+ StateScoped ( IsPaused :: Paused ) ,
453
+ Node {
454
+ // center button
455
+ width : Val :: Percent ( 100. ) ,
456
+ height : Val :: Percent ( 100. ) ,
457
+ justify_content : JustifyContent :: Center ,
458
+ align_items : AlignItems :: Center ,
459
+ flex_direction : FlexDirection :: Column ,
460
+ row_gap : Val :: Px ( 10. ) ,
461
+ position_type : PositionType :: Absolute ,
462
+ ..default ( )
463
+ } ,
464
+ children ! [ (
459
465
Node {
460
- // center button
461
- width : Val :: Percent ( 100 .) ,
462
- height : Val :: Percent ( 100. ) ,
466
+ width : Val :: Px ( 400. ) ,
467
+ height : Val :: Px ( 400 .) ,
468
+ // horizontally center child text
463
469
justify_content: JustifyContent :: Center ,
470
+ // vertically center child text
464
471
align_items: AlignItems :: Center ,
465
- flex_direction : FlexDirection :: Column ,
466
- row_gap : Val :: Px ( 10. ) ,
467
- position_type : PositionType :: Absolute ,
468
472
..default ( )
469
473
} ,
470
- ) )
471
- . with_children ( |parent| {
472
- parent
473
- . spawn ( (
474
- Node {
475
- width : Val :: Px ( 400. ) ,
476
- height : Val :: Px ( 400. ) ,
477
- // horizontally center child text
478
- justify_content : JustifyContent :: Center ,
479
- // vertically center child text
480
- align_items : AlignItems :: Center ,
481
- ..default ( )
482
- } ,
483
- BackgroundColor ( NORMAL_BUTTON ) ,
484
- MenuButton :: Play ,
485
- ) )
486
- . with_children ( |parent| {
487
- parent. spawn ( (
488
- Text :: new ( "Paused" ) ,
489
- TextFont {
490
- font_size : 33.0 ,
491
- ..default ( )
492
- } ,
493
- TextColor ( Color :: srgb ( 0.9 , 0.9 , 0.9 ) ) ,
494
- ) ) ;
495
- } ) ;
496
- } ) ;
474
+ BackgroundColor ( NORMAL_BUTTON ) ,
475
+ MenuButton :: Play ,
476
+ children![ (
477
+ Text :: new( "Paused" ) ,
478
+ TextFont {
479
+ font_size: 33.0 ,
480
+ ..default ( )
481
+ } ,
482
+ TextColor ( Color :: srgb( 0.9 , 0.9 , 0.9 ) ) ,
483
+ ) ] ,
484
+ ) , ] ,
485
+ ) ) ;
497
486
}
498
487
499
488
pub fn setup_turbo_text ( mut commands : Commands ) {
500
- commands
501
- . spawn ( (
502
- StateScoped ( TurboMode ) ,
503
- Node {
504
- // center button
505
- width : Val :: Percent ( 100. ) ,
506
- height : Val :: Percent ( 100. ) ,
507
- justify_content : JustifyContent :: Start ,
508
- align_items : AlignItems :: Center ,
509
- flex_direction : FlexDirection :: Column ,
510
- row_gap : Val :: Px ( 10. ) ,
511
- position_type : PositionType :: Absolute ,
489
+ commands. spawn ( (
490
+ StateScoped ( TurboMode ) ,
491
+ Node {
492
+ // center button
493
+ width : Val :: Percent ( 100. ) ,
494
+ height : Val :: Percent ( 100. ) ,
495
+ justify_content : JustifyContent :: Start ,
496
+ align_items : AlignItems :: Center ,
497
+ flex_direction : FlexDirection :: Column ,
498
+ row_gap : Val :: Px ( 10. ) ,
499
+ position_type : PositionType :: Absolute ,
500
+ ..default ( )
501
+ } ,
502
+ children ! [ (
503
+ Text :: new( "TURBO MODE" ) ,
504
+ TextFont {
505
+ font_size: 33.0 ,
512
506
..default ( )
513
507
} ,
514
- ) )
515
- . with_children ( |parent| {
516
- parent. spawn ( (
517
- Text :: new ( "TURBO MODE" ) ,
518
- TextFont {
519
- font_size : 33.0 ,
520
- ..default ( )
521
- } ,
522
- TextColor ( Color :: srgb ( 0.9 , 0.3 , 0.1 ) ) ,
523
- ) ) ;
524
- } ) ;
508
+ TextColor ( Color :: srgb( 0.9 , 0.3 , 0.1 ) ) ,
509
+ ) ] ,
510
+ ) ) ;
525
511
}
526
512
527
513
pub fn change_color ( time : Res < Time > , mut query : Query < & mut Sprite > ) {
@@ -536,93 +522,88 @@ mod ui {
536
522
}
537
523
538
524
pub fn movement_instructions ( mut commands : Commands ) {
539
- commands
540
- . spawn ( (
541
- StateScoped ( Tutorial :: MovementInstructions ) ,
542
- Node {
543
- // center button
544
- width : Val :: Percent ( 100. ) ,
545
- height : Val :: Percent ( 100. ) ,
546
- justify_content : JustifyContent :: End ,
547
- align_items : AlignItems :: Center ,
548
- flex_direction : FlexDirection :: Column ,
549
- row_gap : Val :: Px ( 10. ) ,
550
- position_type : PositionType :: Absolute ,
551
- ..default ( )
552
- } ,
553
- ) )
554
- . with_children ( |parent| {
555
- parent. spawn ( (
525
+ commands. spawn ( (
526
+ StateScoped ( Tutorial :: MovementInstructions ) ,
527
+ Node {
528
+ // center button
529
+ width : Val :: Percent ( 100. ) ,
530
+ height : Val :: Percent ( 100. ) ,
531
+ justify_content : JustifyContent :: End ,
532
+ align_items : AlignItems :: Center ,
533
+ flex_direction : FlexDirection :: Column ,
534
+ row_gap : Val :: Px ( 10. ) ,
535
+ position_type : PositionType :: Absolute ,
536
+ ..default ( )
537
+ } ,
538
+ children ! [
539
+ (
556
540
Text :: new( "Move the bevy logo with the arrow keys" ) ,
557
541
TextFont {
558
542
font_size: 33.0 ,
559
543
..default ( )
560
544
} ,
561
545
TextColor ( Color :: srgb( 0.3 , 0.3 , 0.7 ) ) ,
562
- ) ) ;
563
- parent . spawn ( (
546
+ ) ,
547
+ (
564
548
Text :: new( "Press T to enter TURBO MODE" ) ,
565
549
TextFont {
566
550
font_size: 33.0 ,
567
551
..default ( )
568
552
} ,
569
553
TextColor ( Color :: srgb( 0.3 , 0.3 , 0.7 ) ) ,
570
- ) ) ;
571
-
572
- parent. spawn ( (
554
+ ) ,
555
+ (
573
556
Text :: new( "Press SPACE to pause" ) ,
574
557
TextFont {
575
558
font_size: 33.0 ,
576
559
..default ( )
577
560
} ,
578
561
TextColor ( Color :: srgb( 0.3 , 0.3 , 0.7 ) ) ,
579
- ) ) ;
580
-
581
- parent. spawn ( (
562
+ ) ,
563
+ (
582
564
Text :: new( "Press ESCAPE to return to the menu" ) ,
583
565
TextFont {
584
566
font_size: 33.0 ,
585
567
..default ( )
586
568
} ,
587
569
TextColor ( Color :: srgb( 0.3 , 0.3 , 0.7 ) ) ,
588
- ) ) ;
589
- } ) ;
570
+ ) ,
571
+ ] ,
572
+ ) ) ;
590
573
}
591
574
592
575
pub fn pause_instructions ( mut commands : Commands ) {
593
- commands
594
- . spawn ( (
595
- StateScoped ( Tutorial :: PauseInstructions ) ,
596
- Node {
597
- // center button
598
- width : Val :: Percent ( 100. ) ,
599
- height : Val :: Percent ( 100. ) ,
600
- justify_content : JustifyContent :: End ,
601
- align_items : AlignItems :: Center ,
602
- flex_direction : FlexDirection :: Column ,
603
- row_gap : Val :: Px ( 10. ) ,
604
- position_type : PositionType :: Absolute ,
605
- ..default ( )
606
- } ,
607
- ) )
608
- . with_children ( |parent| {
609
- parent. spawn ( (
576
+ commands. spawn ( (
577
+ StateScoped ( Tutorial :: PauseInstructions ) ,
578
+ Node {
579
+ // center button
580
+ width : Val :: Percent ( 100. ) ,
581
+ height : Val :: Percent ( 100. ) ,
582
+ justify_content : JustifyContent :: End ,
583
+ align_items : AlignItems :: Center ,
584
+ flex_direction : FlexDirection :: Column ,
585
+ row_gap : Val :: Px ( 10. ) ,
586
+ position_type : PositionType :: Absolute ,
587
+ ..default ( )
588
+ } ,
589
+ children ! [
590
+ (
610
591
Text :: new( "Press SPACE to resume" ) ,
611
592
TextFont {
612
593
font_size: 33.0 ,
613
594
..default ( )
614
595
} ,
615
596
TextColor ( Color :: srgb( 0.3 , 0.3 , 0.7 ) ) ,
616
- ) ) ;
617
-
618
- parent. spawn ( (
597
+ ) ,
598
+ (
619
599
Text :: new( "Press ESCAPE to return to the menu" ) ,
620
600
TextFont {
621
601
font_size: 33.0 ,
622
602
..default ( )
623
603
} ,
624
604
TextColor ( Color :: srgb( 0.3 , 0.3 , 0.7 ) ) ,
625
- ) ) ;
626
- } ) ;
605
+ ) ,
606
+ ] ,
607
+ ) ) ;
627
608
}
628
609
}
0 commit comments