Skip to content

Commit

Permalink
main menu;
Browse files Browse the repository at this point in the history
  • Loading branch information
stillonearth committed Jan 3, 2024
1 parent 11835e4 commit c401097
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ pub struct AvatarAssets {
pub struct CutsceneAssets {
#[asset(path = "cutscenes/phone-call-1.png")]
pub phone_call_1: Handle<Image>,
#[asset(path = "cutscenes/main-menu.png")]
pub main_menu: Handle<Image>,
}

#[derive(Resource)]
Expand Down
44 changes: 42 additions & 2 deletions src/menu.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::loading::TextureAssets;
use crate::CutsceneAssets;
use crate::GameState;
use bevy::prelude::*;
// use rand::Rng;

pub struct MenuPlugin;

Expand Down Expand Up @@ -39,11 +39,50 @@ impl Default for ButtonColors {
#[derive(Component)]
struct Menu;

fn setup_menu(mut commands: Commands, textures: Res<TextureAssets>) {
fn setup_menu(
mut commands: Commands,
textures: Res<TextureAssets>,
cutscene_assets: Res<CutsceneAssets>,
) {
info!("menu");

commands.spawn(Camera2dBundle::default());

commands
.spawn((
NodeBundle {
style: Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
position_type: PositionType::Absolute,
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
},
// background_color: Color::BLACK.into(),
..default()
},
Menu,
Name::new("cutscene image container"),
))
.with_children(|parent| {
// bevy logo (image)
// A `NodeBundle` is used to display the logo the image as an `ImageBundle` can't automatically
// size itself with a child node present.
parent.spawn((
NodeBundle {
style: Style {
width: Val::Px(512.0),
height: Val::Px(512.0),
..default()
},
background_color: Color::WHITE.into(),
..default()
},
UiImage::new(cutscene_assets.main_menu.clone()),
));
});

commands
.spawn((
NodeBundle {
Expand Down Expand Up @@ -88,6 +127,7 @@ fn setup_menu(mut commands: Commands, textures: Res<TextureAssets>) {
));
});
});

commands
.spawn((
NodeBundle {
Expand Down

0 comments on commit c401097

Please sign in to comment.