use gamestates and assetloader
This commit is contained in:
51
src/loading_assets.rs
Normal file
51
src/loading_assets.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
use crate::GameState;
|
||||
use bevy::prelude::*;
|
||||
use bevy_asset_loader::prelude::*;
|
||||
|
||||
#[derive(AssetCollection, Resource)]
|
||||
pub struct AudioAssets {
|
||||
#[asset(path = "sfx/music/02.ogg")]
|
||||
pub music: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/ambient/downtown.ogg")]
|
||||
pub ambient: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/effects/key_collect.ogg")]
|
||||
pub key_collect: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/abilities/gun.ogg")]
|
||||
pub gun: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/effects/gate.ogg")]
|
||||
pub gate: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/effects/cash.ogg")]
|
||||
pub cash: Handle<AudioSource>,
|
||||
#[asset(path = "sfx/hit", collection(typed))]
|
||||
pub hit: Vec<Handle<AudioSource>>,
|
||||
}
|
||||
|
||||
#[derive(AssetCollection, Resource)]
|
||||
pub struct UIAssets {
|
||||
#[asset(path = "font.ttf")]
|
||||
pub font: Handle<Font>,
|
||||
|
||||
#[asset(path = "ui/head_bg.png")]
|
||||
pub head_bg: Handle<Image>,
|
||||
#[asset(path = "ui/head_regular.png")]
|
||||
pub head_regular: Handle<Image>,
|
||||
#[asset(path = "ui/head_damage.png")]
|
||||
pub head_damage: Handle<Image>,
|
||||
#[asset(path = "ui/selector.png")]
|
||||
pub head_selector: Handle<Image>,
|
||||
|
||||
#[asset(path = "ui/camera.png")]
|
||||
pub camera: Handle<Image>,
|
||||
}
|
||||
|
||||
pub struct LoadingPlugin;
|
||||
impl Plugin for LoadingPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_loading_state(
|
||||
LoadingState::new(GameState::AssetLoading)
|
||||
.continue_to_state(GameState::MapLoading)
|
||||
.load_collection::<AudioAssets>()
|
||||
.load_collection::<UIAssets>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user