[][src]Struct bevy_sprite::TextureAtlas

pub struct TextureAtlas {
    pub texture: Handle<Texture>,
    pub size: Vec2,
    pub textures: Vec<Rect>,
    pub texture_handles: Option<HashMap<Handle<Texture>, usize>>,
}

An atlas containing multiple textures (like a spritesheet or a tilemap)

Fields

texture: Handle<Texture>

The handle to the texture in which the sprites are stored

size: Vec2textures: Vec<Rect>

The specific areas of the atlas where each texture can be found

texture_handles: Option<HashMap<Handle<Texture>, usize>>

Implementations

impl TextureAtlas[src]

pub fn new_empty(texture: Handle<Texture>, dimensions: Vec2) -> Self[src]

Create a new TextureAtlas that has a texture, but does not have any individual sprites specified

pub fn from_grid(
    texture: Handle<Texture>,
    tile_size: Vec2,
    columns: usize,
    rows: usize
) -> TextureAtlas
[src]

Generate a TextureAtlas by splitting a texture into a grid where each cell of the grid of tile_size is one of the textures in the atlas

pub fn from_grid_with_padding(
    texture: Handle<Texture>,
    tile_size: Vec2,
    columns: usize,
    rows: usize,
    padding: Vec2
) -> TextureAtlas
[src]

Generate a TextureAtlas by splitting a texture into a grid where each cell of the grid of tile_size is one of the textures in the atlas and is separated by some padding in the texture

pub fn add_texture(&mut self, rect: Rect)[src]

Add a sprite to the list of textures in the TextureAtlas

Arguments

  • rect - The section of the atlas that contains the texture to be added, from the top-left corner of the texture to the bottom-right corner

pub fn len(&self) -> usize[src]

How many textures are in the TextureAtlas

pub fn is_empty(&self) -> bool[src]

pub fn get_texture_index(&self, texture: &Handle<Texture>) -> Option<usize>[src]

Trait Implementations

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Asset for T where
    T: TypeUuid + AssetDynamic + TypeUuidDynamic
[src]

impl<T> AssetDynamic for T where
    T: Send + Sync + 'static + TypeUuidDynamic
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Component for T where
    T: 'static + Send + Sync

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Resource for T where
    T: 'static + Send + Sync
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> TypeUuidDynamic for T where
    T: TypeUuid
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,