-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
screens.rs
119 lines (116 loc) · 5.07 KB
/
screens.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
use bevy::color::palettes;
use bevy::prelude::*;
use bevy_splash_screen::{SplashAssetType, SplashItem, SplashPlugin, SplashScreen};
use bevy_tweening::EaseFunction;
use std::time::Duration;
#[derive(Clone, Copy, Debug, Default, States, Hash, PartialEq, Eq)]
enum ScreenStates {
#[default]
Splash,
Menu,
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.init_state::<ScreenStates>()
.add_plugins(
SplashPlugin::new(ScreenStates::Splash, ScreenStates::Menu)
.add_screen(SplashScreen {
brands: vec![SplashItem {
asset: SplashAssetType::SingleText(
Text::from_sections([
TextSection::new(
"Simple Test\n",
TextStyle {
font_size: 40.,
color: Color::WHITE,
..default()
},
),
TextSection::new(
"by\n",
TextStyle {
font_size: 24.,
color: Color::WHITE.with_alpha(0.75),
..default()
},
),
TextSection::new(
"Sergio Ribera",
TextStyle {
font_size: 32.,
color: Color::WHITE,
..default()
},
),
])
.with_justify(JustifyText::Center),
"FiraSans-Bold.ttf".to_string(),
),
tint: palettes::css::SEA_GREEN.into(),
width: Val::Percent(30.),
height: Val::Px(150.),
ease_function: EaseFunction::QuarticInOut.into(),
duration: Duration::from_secs_f32(5.),
is_static: false,
}],
background_color: BackgroundColor(Color::BLACK),
..default()
})
.add_screen(SplashScreen {
brands: vec![SplashItem {
asset: SplashAssetType::SingleText(
Text::from_sections([TextSection::new(
"With Bevy Engine",
TextStyle {
font_size: 32.,
color: Color::WHITE,
..default()
},
)])
.with_justify(JustifyText::Center),
"FiraSans-Bold.ttf".to_string(),
),
tint: Color::WHITE,
width: Val::Percent(30.),
height: Val::Px(150.),
ease_function: EaseFunction::QuarticInOut.into(),
duration: Duration::from_secs_f32(5.),
is_static: false,
}],
wait_to_start: bevy_splash_screen::WaitScreenType::AfterEnd,
background_color: BackgroundColor(Color::BLACK),
..default()
})
.add_screen(SplashScreen {
brands: vec![SplashItem {
asset: SplashAssetType::SingleText(
Text::from_sections([TextSection::new(
"With Love <3",
TextStyle {
font_size: 32.,
color: Color::WHITE,
..default()
},
)])
.with_justify(JustifyText::Center),
"FiraSans-Bold.ttf".to_string(),
),
tint: Srgba::RED.into(),
width: Val::Percent(30.),
height: Val::Px(150.),
ease_function: EaseFunction::QuarticInOut.into(),
duration: Duration::from_secs_f32(5.),
is_static: false,
}],
wait_to_start: bevy_splash_screen::WaitScreenType::AfterEnd,
background_color: BackgroundColor(Color::WHITE),
..default()
}),
)
.add_systems(Startup, create_scene)
.run();
}
fn create_scene(mut cmd: Commands) {
cmd.spawn(Camera2dBundle::default());
}