-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
layouts.rs
181 lines (178 loc) · 8.47 KB
/
layouts.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
use bevy::color::palettes;
use bevy::prelude::*;
use bevy_splash_screen::{SplashAssetType, SplashItem, SplashPlugin, SplashScreen, SplashType};
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)
.skipable()
.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,
},
SplashItem {
asset: SplashAssetType::SingleText(
Text::from_sections([TextSection::new(
"With Bevy",
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,
},
],
splash_type: SplashType::List,
background_color: BackgroundColor(Color::BLACK),
..default()
})
.add_screen(SplashScreen {
brands: vec![
SplashItem {
asset: SplashAssetType::SingleText(
Text::from_sections([TextSection::new(
"Hola Hola Hola",
TextStyle {
font_size: 32.,
color: Color::WHITE,
..default()
},
)])
.with_justify(JustifyText::Center),
"FiraSans-Bold.ttf".to_string(),
),
tint: palettes::basic::YELLOW.into(),
width: Val::Percent(30.),
height: Val::Px(150.),
ease_function: EaseFunction::QuarticInOut.into(),
duration: Duration::from_secs_f32(5.),
is_static: false,
},
SplashItem {
asset: SplashAssetType::SingleText(
Text::from_sections([TextSection::new(
"Hello Hello Hello",
TextStyle {
font_size: 32.,
color: Color::WHITE,
..default()
},
)])
.with_justify(JustifyText::Center),
"FiraSans-Bold.ttf".to_string(),
),
tint: Srgba::BLUE.into(),
width: Val::Percent(30.),
height: Val::Px(150.),
ease_function: EaseFunction::QuarticInOut.into(),
duration: Duration::from_secs_f32(12.),
is_static: false,
},
SplashItem {
asset: SplashAssetType::SingleText(
Text::from_sections([TextSection::new(
"Test Test Test",
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,
},
SplashItem {
asset: SplashAssetType::SingleText(
Text::from_sections([TextSection::new(
"Bevy Bevy Bevy",
TextStyle {
font_size: 32.,
color: Color::WHITE,
..default()
},
)])
.with_justify(JustifyText::Center),
"FiraSans-Bold.ttf".to_string(),
),
tint: palettes::basic::PURPLE.into(),
width: Val::Percent(30.),
height: Val::Px(150.),
ease_function: EaseFunction::QuarticInOut.into(),
duration: Duration::from_secs_f32(5.),
is_static: false,
},
],
splash_type: SplashType::Grid,
wait_to_start: bevy_splash_screen::WaitScreenType::AfterEnd,
background_color: BackgroundColor(Color::BLACK),
..default()
}),
)
.add_systems(Startup, create_scene)
.run();
}
fn create_scene(mut cmd: Commands) {
cmd.spawn(Camera2dBundle::default());
}