-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spacing fixes #309
Spacing fixes #309
Conversation
@antoinePaulinB7 |
(texture_size.x + tile_spacing.x) / (tile_size.x + tile_spacing.x); | ||
let tile_count_y = | ||
(texture_size.y + tile_spacing.y) / (tile_size.y + tile_spacing.y); | ||
let tile_count_x = ((texture_size.x) / (tile_size.x + tile_spacing.x)).floor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to floor here because otherwise you can get tile counts that are larger than what's available in the atlas.
+ spacing.x; | ||
let sprite_sheet_y: f32 = (i as f32 / columns).floor() | ||
* (tile_size.y + spacing.y) as f32 | ||
+ spacing.y; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't divide by 2 here. This is because spacing is treated as the "space" between tiles. This is what tiled map editor does and I think it's something we should stick with.
@@ -0,0 +1,80 @@ | |||
use bevy::{prelude::*, render::texture::ImageSettings}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple example based off of the layer example(just to show multiple tiles). The spacing is 8 pixels between each tile on both the X and Y axes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this looks good to me!
@antoinePaulinB7 This is similar to your PR, but the main change is that the spacing is to the left/below tiles, rather than all around them. |
Fixes: #260
Closes: #301