Newer
Older
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
use bevy::prelude::*;
#[derive(Clone)]
pub enum SplashAnimationType {
FadeColour { from: Color, to: Color },
Wait,
}
#[derive(Component, Clone)]
pub struct SplashAnimation {
pub duration: f32,
pub anim: SplashAnimationType,
pub then: Option<Box<SplashAnimation>>,
}
#[derive(Component, Clone)]
pub struct SplashAnimationTimer(pub f32);
#[derive(Bundle)]
pub struct SplashAnimationBundle {
animation: SplashAnimation,
timer: SplashAnimationTimer,
}
impl SplashAnimationBundle {
pub fn from_animation(animation: SplashAnimation) -> Self {
Self {
animation,
timer: SplashAnimationTimer(0.0),
}
}
}
impl SplashAnimation {
pub fn fade(
from: Color,
to: Color,
duration: f32,
then: Option<Box<SplashAnimation>>,
) -> SplashAnimation {
SplashAnimation {
anim: SplashAnimationType::FadeColour { from, to },
duration,
then,
}
}
pub fn wait(duration: f32, then: Option<Box<SplashAnimation>>) -> SplashAnimation {
SplashAnimation {
anim: SplashAnimationType::Wait,
duration,
then,
}
}
}