Skip to content
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

Add docs to bevy_sprite a little #10947

Merged
merged 5 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/bevy_sprite/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ use bevy_render::{
};
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
akimakinai marked this conversation as resolved.
Show resolved Hide resolved
pub sprite: Sprite,
/// The local transform of the sprite, relative to its parent
akimakinai marked this conversation as resolved.
Show resolved Hide resolved
pub transform: Transform,
/// The absolute transform of the sprite. This should generally not be written to directly.
pub global_transform: GlobalTransform,
akimakinai marked this conversation as resolved.
Show resolved Hide resolved
/// A reference-counted handle to the image asset to be drawn
akimakinai marked this conversation as resolved.
Show resolved Hide resolved
pub texture: Handle<Image>,
/// User indication of whether an entity is visible
pub visibility: Visibility,
Expand All @@ -24,7 +29,7 @@ pub struct SpriteBundle {
pub view_visibility: ViewVisibility,
}

/// A Bundle of components for drawing a single sprite from a sprite sheet (also referred
/// A [`Bundle`] of components for drawing a single sprite from a sprite sheet (also referred
/// to as a `TextureAtlas`)
akimakinai marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Bundle, Clone, Default)]
pub struct SpriteSheetBundle {
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_sprite/src/collide_aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use bevy_math::{Vec2, Vec3};

/// The side where a collision occurred, as returned by [`collide`]
akimakinai marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum Collision {
Left,
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_sprite/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Provides 2D sprite rendering functionality.
mod bundle;
mod dynamic_texture_atlas_builder;
mod mesh2d;
Expand Down Expand Up @@ -40,11 +41,13 @@ use bevy_render::{
ExtractSchedule, Render, RenderApp, RenderSet,
};

/// Adds support for 2D sprite rendering.
#[derive(Default)]
pub struct SpritePlugin;

pub const SPRITE_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(2763343953151597127);

/// Set system for the systems relating to sprite rendering.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Set system for the systems relating to sprite rendering.
/// System labels for sprite rendering.

The wording is a little weird and "set system" is not a common form.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Set system for the systems relating to sprite rendering.
/// System set for sprite rendering.

Alternative version.

akimakinai marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
pub enum SpriteSystem {
ExtractSprites,
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ pub fn prepare_sprites(
}
}

/// [`RenderCommand`] for sprite rendering.
pub type DrawSprite = (
SetItemPipeline,
SetSpriteViewBindGroup<0>,
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_sprite/src/sprite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use bevy_math::{Rect, Vec2};
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
use bevy_render::color::Color;

/// Specifies the rendering properties of a sprite.
///
/// [`SpriteBundle`](crate::bundle::SpriteBundle) is a bundle for common sprite rendering use cases.
akimakinai marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Component, Debug, Default, Clone, Reflect)]
#[reflect(Component, Default)]
#[repr(C)]
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_sprite/src/texture_atlas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ pub struct TextureAtlas {
pub(crate) texture_handles: Option<HashMap<AssetId<Image>, usize>>,
}

/// Specifies the rendering properties of a sprite from a sprite sheet.
///
/// [`SpriteSheetBundle`](crate::bundle::SpriteSheetBundle) is a bundle for common sprite rendering use cases.
akimakinai marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Component, Debug, Clone, Reflect)]
#[reflect(Component)]
pub struct TextureAtlasSprite {
Expand Down