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]
pub fn new(image: Image) -> Self
[src]
Creates a new SpriteBatch
, drawing with the given image.
pub fn add(&mut self, param: DrawParam) -> SpriteIdx
[src]
Adds a new sprite to the sprite batch.
Returns a handle with whictypeh to modify the sprite using set()
pub fn set(&mut self, handle: SpriteIdx, param: DrawParam) -> GameResult<()>
[src]
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 the contained Image
pub fn set_image(&mut self, image: Image) -> Image
[src]
Replaces the contained Image
, returning the old one.
pub fn with_image<'a>(&'a mut self, image: &'a Image) -> BoundSpriteBatch<'a>
[src]
Create an object which draws the current sprite batch with a different image.
Trait Implementations
impl Debug for SpriteBatch
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for SpriteBatch
[src]
fn clone(&self) -> SpriteBatch
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Drawable for SpriteBatch
[src]
fn draw_ex(&self, ctx: &mut Context, param: DrawParam) -> GameResult<()>
[src]
Actually draws the object to the screen. Read more
fn set_blend_mode(&mut self, mode: Option<BlendMode>)
[src]
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]
Gets the blend mode to be used when drawing this drawable.
fn draw(&self, ctx: &mut Context, dest: Point2, rotation: f32) -> GameResult<()>
[src]
Draws the drawable onto the rendering target. Read more