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

pub struct SpriteBatch { /* fields omitted */ }
Expand description

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.

Implementations

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.

Adds a new sprite to the sprite batch.

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

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

Returns a reference to the sprites.

Returns a mutable reference to the sprites.

Unlike with MeshBatch, manually calling flush after altering sprites in this slice is currently unnecessary, as SpriteBatch flushes automatically on every draw call. This might change in the future though.

Removes all data from the sprite batch.

Unwraps and returns the contained Image

Replaces the contained Image, returning the old one.

Get the filter mode for the SpriteBatch.

Set the filter mode for the SpriteBatch.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Draws the drawable onto the rendering target.

Returns a bounding box in the form of a Rect. Read more

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

Gets the blend mode to be used when drawing this drawable.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.