From 210006be9c2564f965e01187a54c47bd88fe099c Mon Sep 17 00:00:00 2001 From: JP Stringham Date: Tue, 3 Feb 2026 20:36:49 -0500 Subject: [PATCH] Can load all autolayers from LDtk --- src/main.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index b7e4a8d..95357a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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);