Skip to content

Commit

Permalink
feat: update layers Z-offset so the upper layer will be at offset 0 a…
Browse files Browse the repository at this point in the history
…nd layers behind will have negative offset values
  • Loading branch information
adrien-bon committed Sep 8, 2024
1 parent c8bf666 commit 5673d9a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add the possibility for the user to use a custom physics backend and add an associated example (#30)
- Add a note about isometric (staggered) maps which are not supported and add a dedicated example
- Add a bit of documentation
- Update layers Z-offset so the upper layer will be at offset 0 and layers behind will have negative offset values

### Bugfixes

Expand Down
3 changes: 2 additions & 1 deletion src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ fn load_map(

// Order of the differents layers in the .TMX file is important:
// a layer appearing last in the .TMX should appear "on top" of previous layers
let mut offset_z = 0.;
// Start with a negative offset so the upper layer will be at Z-offset = 0
let mut offset_z = tiled_map.map.layers().len() as f32 * (-100.0);

// Once materials have been created/added we need to then create the layers.
for (layer_index, layer) in tiled_map.map.layers().enumerate() {
Expand Down

0 comments on commit 5673d9a

Please sign in to comment.