[][src]Struct ggez::graphics::spritebatch::SpriteBatch

pub struct SpriteBatch { /* fields omitted */ }

A SpriteBatch draws a number of copies of the same image, using a single draw call.

This is generally faster than drawing the same sprite with many invocations of draw(), though it has a bit of overhead to set up the batch. This overhead makes it run very slowly in debug mode because it spends a lot of time on array bounds checking and un-optimized math; you need to build with optimizations enabled to really get the speed boost.


impl SpriteBatch[src]

pub fn new(image: Image) -> Self[src]

Creates a new SpriteBatch, drawing with the given image.

Takes ownership of the Image, but cloning an Image is cheap since they have an internal Arc containing the actual image data.

pub fn add<P>(&mut self, param: P) -> SpriteIdx where
    P: Into<DrawParam>, 

Adds a new sprite to the sprite batch.

Returns a handle with which to modify the sprite using set()

pub fn set<P>(&mut self, handle: SpriteIdx, param: P) -> GameResult where
    P: Into<DrawParam>, 

Alters a sprite in the batch to use the given draw params

pub fn clear(&mut self)[src]

Removes all data from the sprite batch.

pub fn into_inner(self) -> Image[src]

Unwraps and returns the contained Image

pub fn set_image(&mut self, image: Image) -> Image[src]

Replaces the contained Image, returning the old one.

pub fn filter(&self) -> FilterMode[src]

Get the filter mode for the SpriteBatch.

pub fn set_filter(&mut self, mode: FilterMode)[src]

Set the filter mode for the SpriteBatch.

Trait Implementations

impl Drawable for SpriteBatch[src]

impl PartialEq<SpriteBatch> for SpriteBatch[src]

impl Clone for SpriteBatch[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for SpriteBatch[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> Erased for T

impl<T> SetParameter for T

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 

Sets value as a parameter of self.