fix: keep font loaded
This commit is contained in:
parent
214e55d7ac
commit
d9232fd5f0
7 changed files with 25 additions and 25 deletions
|
@ -15,7 +15,6 @@
|
||||||
* (?) can jump only from a surface (no mid-air jump)
|
* (?) can jump only from a surface (no mid-air jump)
|
||||||
* (?) multiplayer
|
* (?) multiplayer
|
||||||
* make WASM build work again (replace hanabi)
|
* make WASM build work again (replace hanabi)
|
||||||
* Text is not displayed after menu (on win state and on game over level)
|
|
||||||
* level reset
|
* level reset
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
Binary file not shown.
BIN
assets/UacariLegacy-Thin.ttf
Normal file
BIN
assets/UacariLegacy-Thin.ttf
Normal file
Binary file not shown.
31
src/game.rs
31
src/game.rs
|
@ -223,7 +223,6 @@ fn collision_event_system(
|
||||||
if app_state.current() == &AppState::Game
|
if app_state.current() == &AppState::Game
|
||||||
&& 4. - new_color.length_squared() < 0.1
|
&& 4. - new_color.length_squared() < 0.1
|
||||||
{
|
{
|
||||||
println!("win");
|
|
||||||
app_state.replace(AppState::Win).ok();
|
app_state.replace(AppState::Win).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,22 +325,22 @@ fn keyboard_input_system(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: the text is not visible, I don't know why.
|
|
||||||
fn win_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn win_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
println!("win system");
|
let font = asset_server.get_handle("UacariLegacy-Thin.ttf");
|
||||||
let font = asset_server.get_handle("Cantarell-VF.otf");
|
commands
|
||||||
commands.spawn_bundle(Text2dBundle {
|
.spawn_bundle(Text2dBundle {
|
||||||
text: Text::from_section(
|
text: Text::from_section(
|
||||||
"Press ENTER to level up",
|
"Press ENTER to level up",
|
||||||
TextStyle {
|
TextStyle {
|
||||||
font,
|
font,
|
||||||
font_size: 32.0,
|
font_size: 32.0,
|
||||||
color: Color::WHITE,
|
color: Color::WHITE,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_alignment(TextAlignment::CENTER),
|
.with_alignment(TextAlignment::CENTER),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
})
|
||||||
|
.insert(Level);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sounds
|
// Sounds
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::game::*;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
pub fn setup(commands: &mut Commands, asset_server: &Res<AssetServer>) {
|
pub fn setup(commands: &mut Commands, asset_server: &Res<AssetServer>) {
|
||||||
let font = asset_server.get_handle("Cantarell-VF.otf");
|
let font = asset_server.get_handle("UacariLegacy-Thin.ttf");
|
||||||
commands
|
commands
|
||||||
.spawn_bundle(Text2dBundle {
|
.spawn_bundle(Text2dBundle {
|
||||||
text: Text::from_section(
|
text: Text::from_section(
|
||||||
|
@ -15,7 +15,7 @@ pub fn setup(commands: &mut Commands, asset_server: &Res<AssetServer>) {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_alignment(TextAlignment::CENTER),
|
.with_alignment(TextAlignment::CENTER),
|
||||||
transform: Transform::from_xyz(0., -128.0, 0.),
|
transform: Transform::from_xyz(0., 128.0, 0.),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.insert(Level);
|
.insert(Level);
|
||||||
|
|
|
@ -33,6 +33,7 @@ fn main() {
|
||||||
.add_plugin(RapierDebugRenderPlugin::default())
|
.add_plugin(RapierDebugRenderPlugin::default())
|
||||||
.add_plugin(menu::MenuPlugin)
|
.add_plugin(menu::MenuPlugin)
|
||||||
.add_plugin(game::GamePlugin)
|
.add_plugin(game::GamePlugin)
|
||||||
|
.add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new())
|
||||||
.add_startup_system(setup)
|
.add_startup_system(setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
@ -42,7 +43,8 @@ fn setup(
|
||||||
mut dsp_manager: ResMut<DspManager>,
|
mut dsp_manager: ResMut<DspManager>,
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
) {
|
) {
|
||||||
let _font: Handle<Font> = asset_server.load("Cantarell-VF.otf");
|
let font: Handle<Font> = asset_server.load("UacariLegacy-Thin.ttf");
|
||||||
|
commands.insert_resource(font);
|
||||||
|
|
||||||
commands.spawn_bundle(Camera2dBundle {
|
commands.spawn_bundle(Camera2dBundle {
|
||||||
camera_2d: Camera2d {
|
camera_2d: Camera2d {
|
||||||
|
|
10
src/menu.rs
10
src/menu.rs
|
@ -8,7 +8,7 @@ use bevy::{
|
||||||
pub struct MenuPlugin;
|
pub struct MenuPlugin;
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct Menu();
|
struct Menu;
|
||||||
|
|
||||||
impl Plugin for MenuPlugin {
|
impl Plugin for MenuPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
|
@ -19,7 +19,7 @@ impl Plugin for MenuPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
let font = asset_server.get_handle("Cantarell-VF.otf");
|
let font = asset_server.get_handle("UacariLegacy-Thin.ttf");
|
||||||
commands
|
commands
|
||||||
.spawn_bundle(Text2dBundle {
|
.spawn_bundle(Text2dBundle {
|
||||||
text: Text::from_section(
|
text: Text::from_section(
|
||||||
|
@ -31,10 +31,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_alignment(TextAlignment::CENTER),
|
.with_alignment(TextAlignment::CENTER),
|
||||||
transform: Transform::from_xyz(0., -128.0, 0.),
|
transform: Transform::from_xyz(0., 128.0, 0.),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.insert(Menu());
|
.insert(Menu);
|
||||||
commands
|
commands
|
||||||
.spawn_bundle(Text2dBundle {
|
.spawn_bundle(Text2dBundle {
|
||||||
text: Text::from_section(
|
text: Text::from_section(
|
||||||
|
@ -48,7 +48,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
.with_alignment(TextAlignment::CENTER),
|
.with_alignment(TextAlignment::CENTER),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.insert(Menu());
|
.insert(Menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn despawn(mut commands: Commands, menu_query: Query<Entity, With<Menu>>) {
|
fn despawn(mut commands: Commands, menu_query: Query<Entity, With<Menu>>) {
|
||||||
|
|
Loading…
Reference in a new issue