pub struct TileSet<Key: Hash + Eq> { /* private fields */ }
Expand description
A set of tiles made from a tilesheet image.
Implementations§
Source§impl<Key: Hash + Eq> TileSet<Key>
impl<Key: Hash + Eq> TileSet<Key>
Sourcepub fn new<S: Into<Vector2<i32>>>(sheet: Image, tile_size: S) -> Self
pub fn new<S: Into<Vector2<i32>>>(sheet: Image, tile_size: S) -> Self
Create a new TileSet
from an image and tile size.
Sourcepub fn register_tile<I: Into<Point2<i32>>>(
&mut self,
key: Key,
index: I,
) -> Result<(), TileSetError>
pub fn register_tile<I: Into<Point2<i32>>>( &mut self, key: Key, index: I, ) -> Result<(), TileSetError>
Register a tile from the tilesheet to the TileSet
with the lookup
value of key
.
Sourcepub fn queue_tile<P: Into<Point2<i32>>, TP: Into<TileParams>>(
&mut self,
key: Key,
draw_location: P,
options: Option<TP>,
) -> Result<(), TileSetError>
pub fn queue_tile<P: Into<Point2<i32>>, TP: Into<TileParams>>( &mut self, key: Key, draw_location: P, options: Option<TP>, ) -> Result<(), TileSetError>
Queue a tile with the lookup value key
to be drawn at draw_location
,
with extra drawing options.
Sourcepub fn clear_queue(&mut self)
pub fn clear_queue(&mut self)
Clear the tile queue.
Sourcepub fn draw(&self, ctx: &mut Context) -> GameResult
pub fn draw(&self, ctx: &mut Context) -> GameResult
Draw the tiles using ctx
&& ‘spritebatch’. Default parameters
are given to the batch.
Auto Trait Implementations§
impl<Key> Freeze for TileSet<Key>
impl<Key> !RefUnwindSafe for TileSet<Key>
impl<Key> Send for TileSet<Key>where
Key: Send,
impl<Key> Sync for TileSet<Key>where
Key: Sync,
impl<Key> Unpin for TileSet<Key>where
Key: Unpin,
impl<Key> !UnwindSafe for TileSet<Key>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> SetParameter for T
impl<T> SetParameter for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.