Can load all autolayers from LDtk

This commit is contained in:
JP Stringham
2026-02-03 20:36:49 -05:00
parent 91e9e622de
commit 210006be9c

View File

@@ -5,8 +5,8 @@ use bevy::{image::Image, prelude::*};
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, States)]
enum AppState {
#[default]
Preload,
Setup,
Preload,
Main,
}
@@ -67,11 +67,8 @@ fn init(
let lvl = &lvl.ldtk_proj.levels[0];
let mut lyr_dep = 50f32;
lvl.layer_instances.iter().for_each(|li| {
if li.ty != ldtk::LayerType::AutoLayer {
return;
}
li.al_tiles.iter().for_each(|t| {
commands.spawn((
Sprite::from_atlas_image(
@@ -81,9 +78,10 @@ fn init(
index: t.ty as usize,
},
),
Transform::from_xyz(t.px_coords.x as f32, 256. - t.px_coords.y as f32, 0.),
Transform::from_xyz(t.px_coords.x as f32, 256. - t.px_coords.y as f32, lyr_dep),
));
});
lyr_dep -= 0.1;
});
state.set(AppState::Preload);