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
use bevy::prelude::*;
use kayak_ui::prelude::{widgets::*, *};
#[derive(Default, Clone, Copy, PartialEq, Hash, Eq, Debug, States)]
pub enum GameState {
#[default]
First,
Second,
}
fn first_sys(mut state: ResMut<NextState<GameState>>) {
state.set(GameState::Second);
}
fn second_sys(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut font_mapping: ResMut<FontMapping>,
) {
let camera_entity = commands
.spawn((Camera2dBundle::default(), CameraUIKayak))
.id();
font_mapping.set_default(asset_server.load("roboto.kayak_font"));
let mut widget_context = KayakRootContext::new(camera_entity);
widget_context.add_plugin(KayakWidgetsContextPlugin);
let parent_id = None;
rsx! {
<KayakAppBundle>
<TextWidgetBundle
text={TextProps {
content: "Hello World".into(),
size: 20.0,
..Default::default()
}}
/>
</KayakAppBundle>
};
commands.spawn((widget_context, EventDispatcher::default()));
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins((KayakContextPlugin, KayakWidgets))
.init_state::<GameState>()
.add_systems(OnEnter(GameState::First), first_sys)
.add_systems(OnEnter(GameState::Second), second_sys)
.run();
}