[−][src]Struct ggez::graphics::spritebatch::SpriteBatch
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.
Methods
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>,
[src]
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>,
[src]
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]
fn draw(&self, ctx: &mut Context, param: DrawParam) -> GameResult
[src]
fn dimensions(&self, _ctx: &mut Context) -> Option<Rect>
[src]
fn set_blend_mode(&mut self, mode: Option<BlendMode>)
[src]
fn blend_mode(&self) -> Option<BlendMode>
[src]
impl PartialEq<SpriteBatch> for SpriteBatch
[src]
fn eq(&self, other: &SpriteBatch) -> bool
[src]
fn ne(&self, other: &SpriteBatch) -> bool
[src]
impl Clone for SpriteBatch
[src]
fn clone(&self) -> 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
impl Unpin for SpriteBatch
impl Sync for SpriteBatch
impl Send for SpriteBatch
impl !RefUnwindSafe for SpriteBatch
impl !UnwindSafe for SpriteBatch
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
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>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> 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>,
T: Parameter<Self>,
Sets value
as a parameter of self
.