
# Objective - bevy_sprite crate is missing docs for important types. `Sprite` being undocumented was especially confusing for me even though it is one of the first types I need to learn. ## Solution - Improves the situation a little by adding some documentations. I'm unsure about my understanding of functionality and writing. I'm happy to be pointed out any mistakes. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Federico Rinaldi <gisquerin@gmail.com>
49 lines
2.0 KiB
Rust
49 lines
2.0 KiB
Rust
use crate::{
|
|
texture_atlas::{TextureAtlas, TextureAtlasSprite},
|
|
Sprite,
|
|
};
|
|
use bevy_asset::Handle;
|
|
use bevy_ecs::bundle::Bundle;
|
|
use bevy_render::{
|
|
texture::Image,
|
|
view::{InheritedVisibility, ViewVisibility, Visibility},
|
|
};
|
|
use bevy_transform::components::{GlobalTransform, Transform};
|
|
|
|
/// A [`Bundle`] of components for drawing a single sprite from an image.
|
|
#[derive(Bundle, Clone, Default)]
|
|
pub struct SpriteBundle {
|
|
/// Specifies the rendering properties of the sprite, such as color tint and flip.
|
|
pub sprite: Sprite,
|
|
/// The local transform of the sprite, relative to its parent.
|
|
pub transform: Transform,
|
|
/// The absolute transform of the sprite. This should generally not be written to directly.
|
|
pub global_transform: GlobalTransform,
|
|
/// A reference-counted handle to the image asset to be drawn.
|
|
pub texture: Handle<Image>,
|
|
/// User indication of whether an entity is visible
|
|
pub visibility: Visibility,
|
|
/// Inherited visibility of an entity.
|
|
pub inherited_visibility: InheritedVisibility,
|
|
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
|
|
pub view_visibility: ViewVisibility,
|
|
}
|
|
|
|
/// A [`Bundle`] of components for drawing a single sprite from a sprite sheet (also referred
|
|
/// to as a `TextureAtlas`).
|
|
#[derive(Bundle, Clone, Default)]
|
|
pub struct SpriteSheetBundle {
|
|
/// The specific sprite from the texture atlas to be drawn, defaulting to the sprite at index 0.
|
|
pub sprite: TextureAtlasSprite,
|
|
/// A handle to the texture atlas that holds the sprite images
|
|
pub texture_atlas: Handle<TextureAtlas>,
|
|
/// Data pertaining to how the sprite is drawn on the screen
|
|
pub transform: Transform,
|
|
pub global_transform: GlobalTransform,
|
|
/// User indication of whether an entity is visible
|
|
pub visibility: Visibility,
|
|
pub inherited_visibility: InheritedVisibility,
|
|
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering
|
|
pub view_visibility: ViewVisibility,
|
|
}
|