This commit is contained in:
Piotr Siuszko 2025-01-14 12:25:16 +01:00
parent c7a56c6060
commit 0bd267570c
3 changed files with 8 additions and 8 deletions

View File

@ -37,13 +37,13 @@ fn on_loaded(
continue;
};
if let Ok(sprite) = assets.try_make_sprite_from_atlas("agents/spaceAstronauts_005") {
if let Ok(sprite) = assets.try_make_sprite("agents/spaceAstronauts_005") {
commands.spawn(Sprite {
color: Color::linear_rgb(1.0, 0.0, 0.0),
..sprite
});
};
if let Ok(image_node) = assets.try_make_image_node_from_atlas("agents/spaceShips_006") {
if let Ok(image_node) = assets.try_make_image_node("agents/spaceShips_006") {
commands.spawn(image_node);
}
}

View File

@ -30,13 +30,13 @@ fn on_loaded(
continue;
};
if let Ok(sprite) = assets.try_make_sprite_from_atlas("agents/spaceAstronauts_005") {
if let Ok(sprite) = assets.try_make_sprite("agents/spaceAstronauts_005") {
commands.spawn(Sprite {
color: Color::linear_rgb(1.0, 0.0, 0.0),
..sprite
});
};
if let Ok(image_node) = assets.try_make_image_node_from_atlas("agents/spaceShips_006") {
if let Ok(image_node) = assets.try_make_image_node("agents/spaceShips_006") {
commands.spawn(image_node);
}
}

View File

@ -47,9 +47,9 @@ pub trait RpackAssetHelper {
key: T,
) -> Result<(TextureAtlas, Handle<Image>), RpackAtlasError>;
/// Creates a [`Sprite`] component for the given atlas key, if available in any of the loaded Atlases.
fn try_make_sprite_from_atlas<T: AsRef<str>>(&self, key: T) -> Result<Sprite, RpackAtlasError>;
fn try_make_sprite<T: AsRef<str>>(&self, key: T) -> Result<Sprite, RpackAtlasError>;
/// Creates a [`ImageNode`] component for the given atlas key, if available in any of the loaded Atlases.
fn try_make_image_node_from_atlas<T: AsRef<str>>(
fn try_make_image_node<T: AsRef<str>>(
&self,
key: T,
) -> Result<ImageNode, RpackAtlasError>;
@ -79,7 +79,7 @@ impl RpackAssetHelper for Assets<RpackAtlasAsset> {
Err(RpackAtlasError::WrongKey)
}
fn try_make_sprite_from_atlas<T: AsRef<str>>(&self, key: T) -> Result<Sprite, RpackAtlasError> {
fn try_make_sprite<T: AsRef<str>>(&self, key: T) -> Result<Sprite, RpackAtlasError> {
if self.is_empty() {
return Err(RpackAtlasError::NoAtlas);
}
@ -91,7 +91,7 @@ impl RpackAssetHelper for Assets<RpackAtlasAsset> {
Err(RpackAtlasError::WrongKey)
}
fn try_make_image_node_from_atlas<T: AsRef<str>>(
fn try_make_image_node<T: AsRef<str>>(
&self,
key: T,
) -> Result<ImageNode, RpackAtlasError> {