use asset server for impact atlas
This commit is contained in:
@@ -38,6 +38,12 @@ pub struct UIAssets {
|
||||
pub camera: Handle<Image>,
|
||||
}
|
||||
|
||||
#[derive(AssetCollection, Resource)]
|
||||
pub struct GameAssets {
|
||||
#[asset(path = "textures/fx/impact.png")]
|
||||
pub impact_atlas: Handle<Image>,
|
||||
}
|
||||
|
||||
pub struct LoadingPlugin;
|
||||
impl Plugin for LoadingPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
@@ -45,6 +51,7 @@ impl Plugin for LoadingPlugin {
|
||||
LoadingState::new(GameState::AssetLoading)
|
||||
.continue_to_state(GameState::MapLoading)
|
||||
.load_collection::<AudioAssets>()
|
||||
.load_collection::<GameAssets>()
|
||||
.load_collection::<UIAssets>(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ use crate::{
|
||||
GameState,
|
||||
aim::AimState,
|
||||
billboards::Billboard,
|
||||
loading_assets::GameAssets,
|
||||
npc::Hit,
|
||||
physics_layers::GameLayer,
|
||||
player::{Player, PlayerRig},
|
||||
@@ -49,18 +50,12 @@ pub fn plugin(app: &mut App) {
|
||||
app.add_observer(on_trigger_state);
|
||||
}
|
||||
|
||||
fn setup(
|
||||
mut commands: Commands,
|
||||
asset_server: Res<AssetServer>,
|
||||
mut sprite_params: Sprite3dParams,
|
||||
) {
|
||||
// TODO: use asset server
|
||||
let image = asset_server.load("textures/fx/impact.png");
|
||||
fn setup(mut commands: Commands, assets: Res<GameAssets>, mut sprite_params: Sprite3dParams) {
|
||||
let layout = TextureAtlasLayout::from_grid(UVec2::splat(256), 7, 6, None, None);
|
||||
let texture_atlas_layout = sprite_params.atlas_layouts.add(layout);
|
||||
|
||||
commands.insert_resource(ShotAssets {
|
||||
image,
|
||||
image: assets.impact_atlas.clone(),
|
||||
layout: texture_atlas_layout,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user