Can load all autolayers from LDtk
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -5,8 +5,8 @@ use bevy::{image::Image, prelude::*};
|
|||||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, States)]
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, States)]
|
||||||
enum AppState {
|
enum AppState {
|
||||||
#[default]
|
#[default]
|
||||||
Preload,
|
|
||||||
Setup,
|
Setup,
|
||||||
|
Preload,
|
||||||
Main,
|
Main,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,11 +67,8 @@ fn init(
|
|||||||
|
|
||||||
let lvl = &lvl.ldtk_proj.levels[0];
|
let lvl = &lvl.ldtk_proj.levels[0];
|
||||||
|
|
||||||
|
let mut lyr_dep = 50f32;
|
||||||
lvl.layer_instances.iter().for_each(|li| {
|
lvl.layer_instances.iter().for_each(|li| {
|
||||||
if li.ty != ldtk::LayerType::AutoLayer {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
li.al_tiles.iter().for_each(|t| {
|
li.al_tiles.iter().for_each(|t| {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Sprite::from_atlas_image(
|
Sprite::from_atlas_image(
|
||||||
@@ -81,9 +78,10 @@ fn init(
|
|||||||
index: t.ty as usize,
|
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);
|
state.set(AppState::Preload);
|
||||||
|
|||||||
Reference in New Issue
Block a user