diff --git a/crates/bevy_sprite/src/texture_atlas.rs b/crates/bevy_sprite/src/texture_atlas.rs index ae94e77b2bad6..53cc9cadd6be2 100644 --- a/crates/bevy_sprite/src/texture_atlas.rs +++ b/crates/bevy_sprite/src/texture_atlas.rs @@ -67,31 +67,21 @@ impl TextureAtlas { } } - /// Generate a `TextureAtlas` by splitting a texture into a grid where each - /// `tile_size` by `tile_size` grid-cell is one of the textures in the - /// atlas. Resulting `TextureAtlas` is indexed left to right, top to bottom. - pub fn from_grid( - texture: Handle, - tile_size: Vec2, - columns: usize, - rows: usize, - ) -> TextureAtlas { - Self::from_grid_with_padding(texture, tile_size, columns, rows, Vec2::ZERO, Vec2::ZERO) - } - /// Generate a `TextureAtlas` by splitting a texture into a grid where each /// `tile_size` by `tile_size` grid-cell is one of the textures in the /// atlas. Grid cells are separated by some `padding`, and the grid starts /// at `offset` pixels from the top left corner. Resulting `TextureAtlas` is /// indexed left to right, top to bottom. - pub fn from_grid_with_padding( + pub fn from_grid( texture: Handle, tile_size: Vec2, columns: usize, rows: usize, - padding: Vec2, - offset: Vec2, + padding: Option, + offset: Option, ) -> TextureAtlas { + let padding = padding.unwrap_or_default(); + let offset = offset.unwrap_or_default(); let mut sprites = Vec::new(); let mut current_padding = Vec2::ZERO; diff --git a/examples/2d/sprite_sheet.rs b/examples/2d/sprite_sheet.rs index b1164286daf09..c5366f55116dd 100644 --- a/examples/2d/sprite_sheet.rs +++ b/examples/2d/sprite_sheet.rs @@ -39,7 +39,8 @@ fn setup( mut texture_atlases: ResMut>, ) { let texture_handle = asset_server.load("textures/rpg/chars/gabe/gabe-idle-run.png"); - let texture_atlas = TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1); + let texture_atlas = + TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1, None, None); let texture_atlas_handle = texture_atlases.add(texture_atlas); commands.spawn(Camera2dBundle::default()); commands.spawn(( diff --git a/examples/stress_tests/many_animated_sprites.rs b/examples/stress_tests/many_animated_sprites.rs index 296a4e5454a01..4ea6d9fae01bf 100644 --- a/examples/stress_tests/many_animated_sprites.rs +++ b/examples/stress_tests/many_animated_sprites.rs @@ -46,7 +46,8 @@ fn setup( let half_y = (map_size.y / 2.0) as i32; let texture_handle = assets.load("textures/rpg/chars/gabe/gabe-idle-run.png"); - let texture_atlas = TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1); + let texture_atlas = + TextureAtlas::from_grid(texture_handle, Vec2::new(24.0, 24.0), 7, 1, None, None); let texture_atlas_handle = texture_atlases.add(texture_atlas); // Spawns the camera