pub struct InfiniteTileLayer<'map> { /* private fields */ }
Implementations§
Source§impl<'map> InfiniteTileLayer<'map>
impl<'map> InfiniteTileLayer<'map>
Source§impl<'map> InfiniteTileLayer<'map>
impl<'map> InfiniteTileLayer<'map>
Sourcepub fn get_tile(&self, x: i32, y: i32) -> Option<LayerTile<'map>>
pub fn get_tile(&self, x: i32, y: i32) -> Option<LayerTile<'map>>
Obtains the tile present at the position given.
If the position is empty, this function will return None
.
Sourcepub fn chunks(
&self,
) -> impl ExactSizeIterator<Item = ((i32, i32), Chunk<'map>)> + 'map
pub fn chunks( &self, ) -> impl ExactSizeIterator<Item = ((i32, i32), Chunk<'map>)> + 'map
Returns an iterator over different parts of this map called Chunk
s.
These may not correspond with the chunks in the TMX file, as the chunk size is
implementation defined (see ChunkData::WIDTH
, ChunkData::HEIGHT
).
The iterator item contains the position of the chunk in chunk coordinates along with a reference to the actual chunk at that position.
This iterator doesn’t have any particular order.
§Example
use tiled::ChunkData;
for (chunk_pos, chunk) in infinite_layer.chunks() {
for x in 0..ChunkData::WIDTH as i32 {
for y in 0..ChunkData::HEIGHT as i32 {
if let Some(tile) = chunk.get_tile(x, y) {
let tile_pos = (
chunk_pos.0 * ChunkData::WIDTH as i32 + x,
chunk_pos.1 * ChunkData::HEIGHT as i32 + y,
);
println!("At ({}, {}): {:?}", tile_pos.0, tile_pos.1, tile);
}
}
}
}
Methods from Deref<Target = InfiniteTileLayerData>§
Sourcepub fn get_tile_data(&self, x: i32, y: i32) -> Option<&LayerTileData>
pub fn get_tile_data(&self, x: i32, y: i32) -> Option<&LayerTileData>
Obtains the tile data present at the position given.
If the position given is invalid or the position is empty, this function will return None
.
If you want to get a Tile
instead, use InfiniteTileLayer::get_tile()
.
Sourcepub fn chunk_data(
&self,
) -> impl ExactSizeIterator<Item = ((i32, i32), &ChunkData)>
pub fn chunk_data( &self, ) -> impl ExactSizeIterator<Item = ((i32, i32), &ChunkData)>
Returns an iterator over only the data part of the chunks of this tile layer.
In 99.99% of cases you’ll want to use InfiniteTileLayer::chunks()
instead; Using this method is only
needed if you only require the tile data of the chunks (and no other utilities provided by
the map-wrapped LayerTile
), and you are in dire need for that extra bit of performance.
This iterator doesn’t have any particular order.
Sourcepub fn get_chunk_data(&self, x: i32, y: i32) -> Option<&ChunkData>
pub fn get_chunk_data(&self, x: i32, y: i32) -> Option<&ChunkData>
Obtains a chunk’s data by its position. To obtain the position of the chunk that contains a
tile, use ChunkData::tile_to_chunk_pos()
.
In 99.99% of cases you’ll want to use InfiniteTileLayer::get_chunk()
instead; Using this method is only
needed if you only require the tile data of the chunk (and no other utilities provided by
the map-wrapped LayerTile
), and you are in dire need for that extra bit of performance.
Trait Implementations§
Source§impl<'map> Clone for InfiniteTileLayer<'map>
impl<'map> Clone for InfiniteTileLayer<'map>
Source§fn clone(&self) -> InfiniteTileLayer<'map>
fn clone(&self) -> InfiniteTileLayer<'map>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more