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)
|
||||
* (?) multiplayer
|
||||
* make WASM build work again (replace hanabi)
|
||||
* Text is not displayed after menu (on win state and on game over level)
|
||||
* level reset
|
||||
|
||||
## 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
|
||||
&& 4. - new_color.length_squared() < 0.1
|
||||
{
|
||||
println!("win");
|
||||
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>) {
|
||||
println!("win system");
|
||||
let font = asset_server.get_handle("Cantarell-VF.otf");
|
||||
commands.spawn_bundle(Text2dBundle {
|
||||
text: Text::from_section(
|
||||
"Press ENTER to level up",
|
||||
TextStyle {
|
||||
font,
|
||||
font_size: 32.0,
|
||||
color: Color::WHITE,
|
||||
},
|
||||
)
|
||||
.with_alignment(TextAlignment::CENTER),
|
||||
..Default::default()
|
||||
});
|
||||
let font = asset_server.get_handle("UacariLegacy-Thin.ttf");
|
||||
commands
|
||||
.spawn_bundle(Text2dBundle {
|
||||
text: Text::from_section(
|
||||
"Press ENTER to level up",
|
||||
TextStyle {
|
||||
font,
|
||||
font_size: 32.0,
|
||||
color: Color::WHITE,
|
||||
},
|
||||
)
|
||||
.with_alignment(TextAlignment::CENTER),
|
||||
..Default::default()
|
||||
})
|
||||
.insert(Level);
|
||||
}
|
||||
|
||||
// Sounds
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::game::*;
|
|||
use bevy::prelude::*;
|
||||
|
||||
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
|
||||
.spawn_bundle(Text2dBundle {
|
||||
text: Text::from_section(
|
||||
|
@ -15,7 +15,7 @@ pub fn setup(commands: &mut Commands, asset_server: &Res<AssetServer>) {
|
|||
},
|
||||
)
|
||||
.with_alignment(TextAlignment::CENTER),
|
||||
transform: Transform::from_xyz(0., -128.0, 0.),
|
||||
transform: Transform::from_xyz(0., 128.0, 0.),
|
||||
..Default::default()
|
||||
})
|
||||
.insert(Level);
|
||||
|
|
|
@ -33,6 +33,7 @@ fn main() {
|
|||
.add_plugin(RapierDebugRenderPlugin::default())
|
||||
.add_plugin(menu::MenuPlugin)
|
||||
.add_plugin(game::GamePlugin)
|
||||
.add_plugin(bevy_inspector_egui::WorldInspectorPlugin::new())
|
||||
.add_startup_system(setup)
|
||||
.run();
|
||||
}
|
||||
|
@ -42,7 +43,8 @@ fn setup(
|
|||
mut dsp_manager: ResMut<DspManager>,
|
||||
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 {
|
||||
camera_2d: Camera2d {
|
||||
|
|
10
src/menu.rs
10
src/menu.rs
|
@ -8,7 +8,7 @@ use bevy::{
|
|||
pub struct MenuPlugin;
|
||||
|
||||
#[derive(Component)]
|
||||
struct Menu();
|
||||
struct Menu;
|
||||
|
||||
impl Plugin for MenuPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
|
@ -19,7 +19,7 @@ impl Plugin for MenuPlugin {
|
|||
}
|
||||
|
||||
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
|
||||
.spawn_bundle(Text2dBundle {
|
||||
text: Text::from_section(
|
||||
|
@ -31,10 +31,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||
},
|
||||
)
|
||||
.with_alignment(TextAlignment::CENTER),
|
||||
transform: Transform::from_xyz(0., -128.0, 0.),
|
||||
transform: Transform::from_xyz(0., 128.0, 0.),
|
||||
..Default::default()
|
||||
})
|
||||
.insert(Menu());
|
||||
.insert(Menu);
|
||||
commands
|
||||
.spawn_bundle(Text2dBundle {
|
||||
text: Text::from_section(
|
||||
|
@ -48,7 +48,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||
.with_alignment(TextAlignment::CENTER),
|
||||
..Default::default()
|
||||
})
|
||||
.insert(Menu());
|
||||
.insert(Menu);
|
||||
}
|
||||
|
||||
fn despawn(mut commands: Commands, menu_query: Query<Entity, With<Menu>>) {
|
||||
|
|
Loading…
Reference in a new issue