Struct ggez::graphics::spritebatch::SpriteBatch [−][src]
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 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]
impl SpriteBatch
pub fn new(image: Image) -> Self
[src]
pub fn new(image: Image) -> Self
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(&mut self, param: DrawParam) -> SpriteIdx
[src]
pub fn add(&mut self, param: DrawParam) -> SpriteIdx
Adds a new sprite to the sprite batch.
Returns a handle with which type to modify the sprite using set()
pub fn set(&mut self, handle: SpriteIdx, param: DrawParam) -> GameResult<()>
[src]
pub fn set(&mut self, handle: SpriteIdx, param: DrawParam) -> GameResult<()>
Alters a sprite in the batch to use the given draw params
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Removes all data from the sprite batch.
pub fn into_inner(self) -> Image
[src]
pub fn into_inner(self) -> Image
Unwraps the contained Image
pub fn set_image(&mut self, image: Image) -> Image
[src]
pub fn set_image(&mut self, image: Image) -> Image
Replaces the contained Image
, returning the old one.
pub fn get_filter(&self) -> FilterMode
[src]
pub fn get_filter(&self) -> FilterMode
Get the filter mode for the SpriteBatch.
pub fn set_filter(&mut self, mode: FilterMode)
[src]
pub fn set_filter(&mut self, mode: FilterMode)
Set the filter mode for the SpriteBatch.
pub fn with_image<'a>(&'a mut self, image: &'a Image) -> BoundSpriteBatch<'a>
[src]
pub fn with_image<'a>(&'a mut self, image: &'a Image) -> BoundSpriteBatch<'a>
Create an object which draws the current sprite batch with a different image.
Trait Implementations
impl Debug for SpriteBatch
[src]
impl Debug for SpriteBatch
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for SpriteBatch
[src]
impl Clone for SpriteBatch
fn clone(&self) -> SpriteBatch
[src]
fn clone(&self) -> SpriteBatch
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for SpriteBatch
[src]
impl PartialEq for SpriteBatch
fn eq(&self, other: &SpriteBatch) -> bool
[src]
fn eq(&self, other: &SpriteBatch) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &SpriteBatch) -> bool
[src]
fn ne(&self, other: &SpriteBatch) -> bool
This method tests for !=
.
impl Drawable for SpriteBatch
[src]
impl Drawable for SpriteBatch
fn draw_ex(&self, ctx: &mut Context, param: DrawParam) -> GameResult<()>
[src]
fn draw_ex(&self, ctx: &mut Context, param: DrawParam) -> GameResult<()>
Actually draws the object to the screen. Read more
fn set_blend_mode(&mut self, mode: Option<BlendMode>)
[src]
fn set_blend_mode(&mut self, mode: Option<BlendMode>)
Sets the blend mode to be used when drawing this drawable. This overrides the general graphics::set_blend_mode()
. If None
is set, defers to the blend mode set by graphics::set_blend_mode()
. Read more
fn get_blend_mode(&self) -> Option<BlendMode>
[src]
fn get_blend_mode(&self) -> Option<BlendMode>
Gets the blend mode to be used when drawing this drawable.
fn draw(&self, ctx: &mut Context, dest: Point2, rotation: f32) -> GameResult<()>
[src]
fn draw(&self, ctx: &mut Context, dest: Point2, rotation: f32) -> GameResult<()>
Draws the drawable onto the rendering target. Read more
Auto Trait Implementations
impl Send for SpriteBatch
impl Send for SpriteBatch
impl Sync for SpriteBatch
impl Sync for SpriteBatch